Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big module update #29

Merged
merged 27 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c47de31
Volume: added logic for changing sound volume (Windows Cliend and Ser…
DvaMishkiLapa Nov 30, 2024
1805b14
Client: improved work with event sending time
DvaMishkiLapa Dec 2, 2024
85f389f
Client: minor fixes in code
DvaMishkiLapa Dec 2, 2024
18e9c35
Client: added logic for changing sound volume (Linux Client)
DvaMishkiLapa Dec 2, 2024
9c00274
Readme: update Linux support table
DvaMishkiLapa Dec 2, 2024
524d447
Server: increased sending delays when adjusting the volume
DvaMishkiLapa Dec 2, 2024
734db75
Version: v1.1.1 -> 1.2.0
DvaMishkiLapa Dec 2, 2024
9ed3885
Server: first implementation of the kernel module
DvaMishkiLapa Dec 5, 2024
b65e1df
Server: header files moved to include
DvaMishkiLapa Dec 5, 2024
8c244e1
Server: refactore code in main.cpp
DvaMishkiLapa Dec 6, 2024
50f828d
Server: redesign of interaction logic
DvaMishkiLapa Dec 6, 2024
e5d2e33
Server: added SceShell Authid
DvaMishkiLapa Dec 6, 2024
7483b4c
Server: added PS button support
DvaMishkiLapa Dec 6, 2024
ebcf643
Client: added PS button support (Windows)
DvaMishkiLapa Dec 6, 2024
f1eb6ad
Server; added option to switch off the screen
DvaMishkiLapa Dec 7, 2024
2a4534a
Server: remove old includes
DvaMishkiLapa Dec 7, 2024
0a71696
Server: added loading pic0
DvaMishkiLapa Dec 7, 2024
9fad5da
Server: added delay for screen toggler
DvaMishkiLapa Dec 7, 2024
3f9a0ee
client: Rename environment variable prefix from VITAOXIPAD_ to VITA_ …
santarl Dec 9, 2024
4ac4a73
Server: minor fix
DvaMishkiLapa Dec 9, 2024
a4a4c1a
Server: remove old includes in module
DvaMishkiLapa Dec 9, 2024
b3e59c3
Server: added module version check in app
DvaMishkiLapa Dec 9, 2024
1b3ebeb
Server: wait 1s for receiving first SceCtrlData data
DvaMishkiLapa Dec 9, 2024
7fde37a
Server: fixed sceCtrlSetSamplingMode param
DvaMishkiLapa Dec 9, 2024
d97b9d0
Client: improved trigers power logic for Windows client
DvaMishkiLapa Dec 9, 2024
9a2b975
Merge branch 'main' into big_module_update
DvaMishkiLapa Dec 9, 2024
b35d556
Client: added PS Button support for Linux Client
DvaMishkiLapa Dec 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions client/packages/vita_reports/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ pub struct ButtonsData {
pub square: bool,
pub vol_up: bool,
pub vol_down: bool,
pub ps: bool,
// timestamp: u64;
}

Expand All @@ -34,6 +35,7 @@ impl From<flatbuffers_structs::net_protocol::ButtonsData> for ButtonsData {
square: buttons.square(),
vol_up: buttons.vol_up(),
vol_down: buttons.vol_down(),
ps: buttons.ps(),
// timestamp: buttons.timestamp(),
}
}
Expand Down
2 changes: 2 additions & 0 deletions client/packages/vita_virtual_device/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ impl VitaVirtualDevice<&ConfigBuilder> for VitaDevice {
self.touch_start_time = None;
}

special_buttons = special_buttons.ps_home(report.buttons.ps);

self.touch_state = is_touching;

// Создаем touchpad report
Expand Down
1 change: 1 addition & 0 deletions common/netprotocol.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ struct ButtonsData
square: bool;
vol_up: bool;
vol_down: bool;
ps: bool;
}

struct Vector3
Expand Down
40 changes: 35 additions & 5 deletions server/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
cmake_minimum_required(VERSION 3.15)

# Set up the Vita SDK toolchain
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
Expand All @@ -8,7 +9,7 @@ if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
endif()
endif()


# Application metadata
project(VitaOxiPad)
include("${VITASDK}/share/vita.cmake" REQUIRED)
set(VITA_APP_NAME "VitaOxiPad")
Expand All @@ -20,19 +21,33 @@ if(DEFINED ENV{VITA_IP})
set(VITA_IP $ENV{VITA_IP})
santarl marked this conversation as resolved.
Show resolved Hide resolved
endif()

# Compiler options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d PARENTAL_LEVEL=1")
set(VITA_MAKE_FSELF_FLAGS "${VITA_MAKE_FSELF_FLAGS} -a 0x2800000000000001")

# Build FlatBuffers
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../cmake/")
include(BuildFlatBuffers)

add_subdirectory(module)

link_directories(
${CMAKE_CURRENT_BINARY_DIR}
)

# Include directories
include_directories(
./include
../include
module/include
${CMAKE_CURRENT_BINARY_DIR}/module
${CMAKE_BINARY_DIR}/generated
)

link_directories(${CMAKE_CURRENT_BINARY_DIR}/module)

file(GLOB SRC_FLATBUFFERS
../common/*.fbs
)
Expand All @@ -47,21 +62,29 @@ build_flatbuffers("${SRC_FLATBUFFERS}"

include_directories(${CMAKE_BINARY_DIR}/generated)

# App Source files
add_executable(${VITA_APP_NAME}
src/status.cpp
src/ctrl.cpp
src/main.cpp
src/net.cpp
src/status.cpp
src/ctrl.cpp
src/thread_helper.cpp
src/draw_helper.cpp
)

add_compile_definitions(FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE)
target_compile_options(${VITA_APP_NAME} PRIVATE -Wall -Wextra -Wpedantic -Werror)

# Dependencies
add_dependencies(${VITA_APP_NAME} flatbuffers_target)
add_dependencies(${VITA_APP_NAME} kctrl_all)

# Libraries
target_link_libraries(${VITA_APP_NAME}
stdc++
vita2d
kctrl_stub_weak
taihen_stub
SceCtrl_stub
SceTouch_stub
SceDisplay_stub
Expand All @@ -71,26 +94,32 @@ target_link_libraries(${VITA_APP_NAME}
ScePower_stub
SceCommonDialog_stub
SceGxm_stub
SceVshBridge_stub
SceShellSvc_stub
SceLibDbg_stub
)

# Create the application self and VPK
vita_create_self(${VITA_APP_NAME}.self ${VITA_APP_NAME})
vita_create_vpk(${VITA_APP_NAME}.vpk ${VITA_TITLEID} ${VITA_APP_NAME}.self
VERSION ${VITA_VERSION}
NAME ${VITA_APP_NAME}
FILE sce_sys/icon0.png sce_sys/icon0.png
FILE sce_sys/pic0.png sce_sys/pic0.png
FILE sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
FILE sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
FILE sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
FILE ${CMAKE_CURRENT_BINARY_DIR}/module/kctrl.skprx module/kctrl.skprx
)

# Send the VPK directly to the PS Vita

# Optional: Send the VPK directly to the PS Vita
if (VITA_IP)
add_custom_target(send
COMMAND "echo" destroy | nc ${VITA_IP} 1338
COMMAND "sleep" 1s
COMMAND unzip -o ${VITA_APP_NAME}.vpk eboot.bin -d ${CMAKE_BINARY_DIR}
COMMAND "curl" --ftp-method nocwd -T ${CMAKE_BINARY_DIR}/eboot.bin "ftp://${VITA_IP}:1337/ux0:/app/${VITA_TITLEID}/"
COMMAND "curl" --ftp-method nocwd -T ${CMAKE_BINARY_DIR}/module/kctrl.skprx "ftp://${VITA_IP}:1337/ux0:/app/${VITA_TITLEID}/module/"
COMMAND "echo" launch ${VITA_TITLEID} | nc ${VITA_IP} 1338
DEPENDS ${VITA_APP_NAME}.vpk
)
Expand All @@ -100,6 +129,7 @@ if(DEFINED ENV{VITA_IP})
set(PARSECOREPATH $ENV{PARSECOREPATH})
endif()

# Optional: Dump debugging information
add_custom_target(dump
COMMAND ${CMAKE_SOURCE_DIR}/get_dump.sh ${VITA_IP}
COMMAND python3 ${PARSECOREPATH} coredump ${CMAKE_PROJECT_NAME}
Expand Down
File renamed without changes.
14 changes: 14 additions & 0 deletions server/include/ctrl.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef __CTRL_H__
#define __CTRL_H__

#include <netprotocol_generated.h>

#include "events.hpp"

void get_ctrl(SceCtrlData *pad, SceMotionState *motion_data, SceTouchData *touch_data_front,
SceTouchData *touch_data_back);
void ctrl_as_netprotocol(SceCtrlData *pad, SceMotionState *motion_data,
SceTouchData *touch_data_front, SceTouchData *touch_data_back,
flatbuffers::FlatBufferBuilder &builder, int battery_level);

#endif // __CTRL_H__
20 changes: 20 additions & 0 deletions server/include/draw_helper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <vita2d.h>

#include "events.hpp"

#ifndef DRAW_HELPER_HPP
#define DRAW_HELPER_HPP

extern vita2d_pgf *debug_font;
extern uint32_t need_color;
extern uint32_t common_color;
extern uint32_t error_color;
extern uint32_t done_color;

void draw_rectangle_outline(float x, float y, float width, float height, uint32_t color);
void draw_start_mode(bool connected_to_network, bool pc_connect_state, char *vita_ip,
SharedData *shared_data);
void draw_pad_mode(bool connected_to_network, bool pc_connect_state, char *vita_ip,
SharedData *shared_data);

#endif // DRAW_HELPER_HPP
21 changes: 11 additions & 10 deletions server/src/events.hpp → server/include/events.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#ifndef EVENTS_HPP
#define EVENTS_HPP

#include <psp2/ctrl.h>
#include <psp2/kernel/threadmgr.h>
#include <psp2/net/net.h>
#include <psp2/net/netctl.h>
#include <psp2/net/netctl.h>

#include <arpa/inet.h>

Expand All @@ -13,15 +11,15 @@

enum MainEvent {
// For NetThread
PC_DISCONNECT = 1 << 0, // 0x0001
PC_CONNECT = 1 << 1, // 0x0002
NET_CONNECT = 1 << 2, // 0x0004
NET_DISCONNECT = 1 << 3, // 0x0008
PC_DISCONNECT = 1 << 0, // 0x0001
PC_CONNECT = 1 << 1, // 0x0002
NET_CONNECT = 1 << 2, // 0x0004
NET_DISCONNECT = 1 << 3, // 0x0008

// For StatusThread
BATTERY_LEVEL = 1 << 8, // 0x0100
STATUS_CHARGER = 1 << 9, // 0x0200
WIFI_SIGNAL = 1 << 10, // 0x0400
BATTERY_LEVEL = 1 << 8, // 0x0100
STATUS_CHARGER = 1 << 9, // 0x0200
WIFI_SIGNAL = 1 << 10, // 0x0400
};

struct SharedData {
Expand All @@ -30,6 +28,9 @@ struct SharedData {
bool charger_connected = false;
unsigned int wifi_signal_strength = 0;
char client_ip[INET_ADDRSTRLEN] = "N/A";
SceCtrlData pad_data;
bool pad_mode = false;
bool display_on = true;
std::mutex mutex;
};

Expand Down
File renamed without changes.
1 change: 0 additions & 1 deletion server/src/net.hpp → server/include/net.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef NET_HPP
#define NET_HPP

#include <psp2/net/net.h>
#include <psp2/net/netctl.h>

#include <atomic>
Expand Down
7 changes: 0 additions & 7 deletions server/src/status.hpp → server/include/status.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
#ifndef STATUS_HPP
#define STATUS_HPP

#include <atomic>
#include <mutex>

#include <psp2/kernel/threadmgr.h>
#include <psp2/net/net.h>
#include <psp2/net/netctl.h>

#include <atomic>

#include "events.hpp"
Expand Down
21 changes: 21 additions & 0 deletions server/include/thread_helper.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <psp2/kernel/threadmgr.h>

#ifndef THREAD_HELPER_HPP
#define THREAD_HELPER_HPP

struct ThreadParams {
const char *name;
SceKernelThreadEntry entry;
int initPriority;
SceSize stackSize;
SceUInt attr;
int cpuAffinityMask;
const SceKernelThreadOptParam *option;
void *threadArgs;
SceSize threadArgSize;
};

SceUID create_and_start_thread(const ThreadParams &params);
int stop_thread(SceUID thread_uid, SceUInt timeout);

#endif // THREAD_HELPER_HPP
58 changes: 58 additions & 0 deletions server/module/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
cmake_minimum_required(VERSION 3.15)

# Set up the Vita SDK toolchain
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "Toolchain file")
else()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
endif()

project(kctrl)
include("${VITASDK}/share/vita.cmake" REQUIRED)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O3 -nostdlib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")

# Add the module's source files
add_executable(${PROJECT_NAME}
src/main.c
)

# Link against necessary kernel stubs
target_link_libraries(${PROJECT_NAME}
SceDebugForDriver_stub
SceCtrlForDriver_stub
SceModulemgrForDriver_stub
SceSysmemForDriver_stub
SceOledForDriver_stub_weak
SceLcdForDriver_stub_weak
)

# Include the module's include directory
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)

# Set linker flags
set_target_properties(${PROJECT_NAME}
PROPERTIES LINK_FLAGS "-nostdlib"
)

# Create the kernel module (skprx)
vita_create_self(${PROJECT_NAME}.skprx ${PROJECT_NAME}
CONFIG kctrl.yml
UNSAFE
)

# Generate stubs for the module
vita_create_stubs(stubs ${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/kctrl.yml KERNEL)
# vita_create_stubs(stubs ${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/kctrl.yml USER)


# Ensure that building the module also builds the stubs
add_custom_target(kctrl_all
ALL
DEPENDS ${PROJECT_NAME}.skprx-self
DEPENDS lib${PROJECT_NAME}_stub.a
DEPENDS lib${PROJECT_NAME}_stub_weak.a
)
19 changes: 19 additions & 0 deletions server/module/include/kctrl-kernel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef _KCTRL_KERNEL_H_
#define _KCTRL_KERNEL_H_

#include <psp2/ctrl.h>

#ifdef __cplusplus
extern "C" {
#endif

void kctrlScreenOn(void);
void kctrlScreenOff(void);
void kctrlToggleScreen(void);
int kctrlGetCtrlData(int port, SceCtrlData *pad_data, int count);

#ifdef __cplusplus
}
#endif

#endif // __KCTRL_KERNEL_H_
16 changes: 16 additions & 0 deletions server/module/kctrl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
kctrl:
attributes: 0
version:
major: 1
minor: 0
main:
start: module_start
stop: module_stop
libraries:
kctrlForKernel:
syscall: true
functions:
- kctrlScreenOn
- kctrlScreenOff
- kctrlToggleScreen
- kctrlGetCtrlData
Loading
Loading