Skip to content

Commit dc4a39d

Browse files
Merge pull request #2 from Swordmaster3214/test
Testing complete
2 parents 4318c9a + 5bf1c9e commit dc4a39d

22 files changed

Lines changed: 1433 additions & 714 deletions

.github/workflows/release-build.yml

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ jobs:
1717
include:
1818
- os: ubuntu-latest
1919
asset: psmoveapi-4.0.12-linux.tar.gz
20-
executable: dsu_server_psmove
2120
- os: macos-13
2221
asset: psmoveapi-4.0.12-macos.tar.gz
23-
executable: dsu_server_psmove
2422
- os: windows-latest
2523
asset: psmoveapi-4.0.12-windows-msvc2017-x64.zip
26-
executable: dsu_server_psmove.exe
2724

2825
steps:
2926
- uses: actions/checkout@v4
@@ -92,30 +89,58 @@ jobs:
9289
fi
9390
shell: bash
9491

92+
- name: Get executable name from CMake
93+
id: cmake_info
94+
run: |
95+
if [ "${{ runner.os }}" = "Windows" ]; then
96+
# For Windows, we need to find the actual executable name
97+
if [ -f "build/Release/"*.exe ]; then
98+
EXEC_NAME=$(basename build/Release/*.exe)
99+
elif [ -f "build/Debug/"*.exe ]; then
100+
EXEC_NAME=$(basename build/Debug/*.exe)
101+
elif [ -f "build/"*.exe ]; then
102+
EXEC_NAME=$(basename build/*.exe)
103+
else
104+
echo "ERROR: Could not find Windows executable"
105+
exit 1
106+
fi
107+
else
108+
# For Linux/macOS, find the executable (non-.exe files that are executable)
109+
EXEC_NAME=$(find build/ -maxdepth 1 -type f -executable ! -name "*.so" ! -name "*.dylib" -printf '%f\n' | head -n1)
110+
if [ -z "$EXEC_NAME" ]; then
111+
echo "ERROR: Could not find executable"
112+
exit 1
113+
fi
114+
fi
115+
echo "executable_name=$EXEC_NAME" >> $GITHUB_OUTPUT
116+
echo "Found executable: $EXEC_NAME"
117+
shell: bash
118+
95119
- name: Find and rename executable
96120
id: artifact
97121
run: |
98122
mkdir -p artifacts
123+
EXEC_NAME="${{ steps.cmake_info.outputs.executable_name }}"
99124
100125
if [ "${{ runner.os }}" = "Windows" ]; then
101126
# Try multiple possible locations for Windows executable
102-
if [ -f "build/Release/${{ matrix.executable }}" ]; then
103-
EXEC_PATH="build/Release/${{ matrix.executable }}"
104-
elif [ -f "build/Debug/${{ matrix.executable }}" ]; then
105-
EXEC_PATH="build/Debug/${{ matrix.executable }}"
106-
elif [ -f "build/${{ matrix.executable }}" ]; then
107-
EXEC_PATH="build/${{ matrix.executable }}"
127+
if [ -f "build/Release/$EXEC_NAME" ]; then
128+
EXEC_PATH="build/Release/$EXEC_NAME"
129+
elif [ -f "build/Debug/$EXEC_NAME" ]; then
130+
EXEC_PATH="build/Debug/$EXEC_NAME"
131+
elif [ -f "build/$EXEC_NAME" ]; then
132+
EXEC_PATH="build/$EXEC_NAME"
108133
else
109-
echo "ERROR: Could not find Windows executable"
134+
echo "ERROR: Could not find Windows executable $EXEC_NAME"
110135
exit 1
111136
fi
112-
ARTIFACT_NAME="dsu_server_psmove-windows-x64.exe"
137+
ARTIFACT_NAME="${EXEC_NAME%.exe}-windows-x64.exe"
113138
elif [ "${{ runner.os }}" = "macOS" ]; then
114-
EXEC_PATH="build/${{ matrix.executable }}"
115-
ARTIFACT_NAME="dsu_server_psmove-macos"
139+
EXEC_PATH="build/$EXEC_NAME"
140+
ARTIFACT_NAME="$EXEC_NAME-macos"
116141
else
117-
EXEC_PATH="build/${{ matrix.executable }}"
118-
ARTIFACT_NAME="dsu_server_psmove-linux"
142+
EXEC_PATH="build/$EXEC_NAME"
143+
ARTIFACT_NAME="$EXEC_NAME-linux"
119144
fi
120145
121146
echo "name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT

CMakeLists.txt

Lines changed: 61 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,36 @@
11
cmake_minimum_required(VERSION 3.10)
22
project(dsu_server_psmove)
3-
43
set(CMAKE_CXX_STANDARD 17)
54

5+
# Determine platform suffix for executable name
6+
if(WIN32)
7+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
8+
set(PLATFORM_SUFFIX "win64")
9+
else()
10+
set(PLATFORM_SUFFIX "win32")
11+
endif()
12+
elseif(APPLE)
13+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
14+
set(PLATFORM_SUFFIX "macos_arm64")
15+
else()
16+
set(PLATFORM_SUFFIX "macos_x64")
17+
endif()
18+
else()
19+
# Linux and other Unix-like systems
20+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
21+
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
22+
set(PLATFORM_SUFFIX "linux_arm64")
23+
else()
24+
set(PLATFORM_SUFFIX "linux_x64")
25+
endif()
26+
else()
27+
set(PLATFORM_SUFFIX "linux_x86")
28+
endif()
29+
endif()
30+
31+
# Set the executable name with platform suffix
32+
set(EXECUTABLE_NAME "dsu_server_psmove_${PLATFORM_SUFFIX}")
33+
634
# Allow user to specify where psmoveapi is located
735
if(NOT DEFINED PSMOVE_ROOT)
836
set(PSMOVE_ROOT "${CMAKE_SOURCE_DIR}/psmoveapi_install")
@@ -15,76 +43,75 @@ endif()
1543

1644
# Include headers
1745
include_directories(${PSMOVE_ROOT}/include)
46+
include_directories(src)
1847

1948
# Add library search path
2049
link_directories(${PSMOVE_ROOT}/lib)
2150

2251
# Source files
23-
add_executable(dsu_server_psmove dsu_server_psmove.cpp)
52+
set(SOURCES
53+
src/main.cpp
54+
src/dsu/dsu_server.cpp
55+
src/dsu/dsu_protocol.cpp
56+
src/psmove/psmove_manager.cpp
57+
src/psmove/psmove_pairing.cpp
58+
src/network/udp_server.cpp
59+
src/utils/logging.cpp
60+
src/utils/signal_handler.cpp
61+
)
62+
63+
# Create executable with platform-specific name
64+
add_executable(${EXECUTABLE_NAME} ${SOURCES})
2465

2566
# Platform-specific libraries
2667
if(WIN32)
27-
# Windows libraries - added winmm for multimedia timer functions
28-
target_link_libraries(dsu_server_psmove
29-
psmoveapi
30-
setupapi
31-
ws2_32
32-
winmm
68+
target_link_libraries(${EXECUTABLE_NAME}
69+
psmoveapi setupapi ws2_32 winmm
3370
)
3471
elseif(APPLE)
35-
# macOS libraries
3672
find_library(USB_LIBRARY usb-1.0 REQUIRED)
3773
find_library(COREFOUNDATION_LIBRARY CoreFoundation REQUIRED)
3874
find_library(IOKIT_LIBRARY IOKit REQUIRED)
3975

40-
target_link_libraries(dsu_server_psmove
41-
psmoveapi
42-
${USB_LIBRARY}
43-
${COREFOUNDATION_LIBRARY}
44-
${IOKIT_LIBRARY}
76+
target_link_libraries(${EXECUTABLE_NAME}
77+
psmoveapi ${USB_LIBRARY} ${COREFOUNDATION_LIBRARY} ${IOKIT_LIBRARY}
4578
)
4679
else()
47-
# Linux
4880
find_package(PkgConfig REQUIRED)
4981
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
5082
pkg_check_modules(BLUETOOTH REQUIRED bluez)
51-
52-
# Check for udev (often needed for device enumeration)
5383
pkg_check_modules(UDEV libudev)
54-
84+
5585
include_directories(${LIBUSB_INCLUDE_DIRS} ${BLUETOOTH_INCLUDE_DIRS})
5686
link_directories(${LIBUSB_LIBRARY_DIRS} ${BLUETOOTH_LIBRARY_DIRS})
57-
58-
set(LINUX_LIBS
59-
psmoveapi
60-
${LIBUSB_LIBRARIES}
61-
${BLUETOOTH_LIBRARIES}
62-
pthread
63-
)
6487

65-
# Add udev if found
88+
set(LINUX_LIBS psmoveapi ${LIBUSB_LIBRARIES} ${BLUETOOTH_LIBRARIES} pthread)
89+
6690
if(UDEV_FOUND)
6791
list(APPEND LINUX_LIBS ${UDEV_LIBRARIES})
6892
include_directories(${UDEV_INCLUDE_DIRS})
6993
link_directories(${UDEV_LIBRARY_DIRS})
7094
endif()
71-
72-
target_link_libraries(dsu_server_psmove ${LINUX_LIBS})
95+
96+
target_link_libraries(${EXECUTABLE_NAME} ${LINUX_LIBS})
7397
endif()
7498

75-
# Set output directory for consistency across platforms
76-
set_target_properties(dsu_server_psmove PROPERTIES
99+
# Set output directory
100+
set_target_properties(${EXECUTABLE_NAME} PROPERTIES
77101
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}
78102
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}
79103
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}
80104
)
81105

82-
# Enable debug info for release builds (useful for debugging)
106+
# Enable debug info for release builds
83107
if(CMAKE_BUILD_TYPE STREQUAL "Release")
84108
if(WIN32)
85-
target_compile_options(dsu_server_psmove PRIVATE /Zi)
86-
target_link_options(dsu_server_psmove PRIVATE /DEBUG)
109+
target_compile_options(${EXECUTABLE_NAME} PRIVATE /Zi)
110+
target_link_options(${EXECUTABLE_NAME} PRIVATE /DEBUG)
87111
else()
88-
target_compile_options(dsu_server_psmove PRIVATE -g)
112+
target_compile_options(${EXECUTABLE_NAME} PRIVATE -g)
89113
endif()
90114
endif()
115+
116+
# Print the final executable name for confirmation
117+
message(STATUS "Building executable: ${EXECUTABLE_NAME}")

README.md

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,26 @@ The server translates PS Move controller input (accelerometer, gyroscope, and bu
2727
### Using Pre-built Binaries
2828

2929
1. **Download** the latest release for your platform:
30-
- [Windows](https://github.com/Swordmaster3214/PSMove-DSU/releases/latest/download/dsu_server_psmove-windows-x64.exe)
31-
- [macOS](https://github.com/Swordmaster3214/PSMove-DSU/releases/latest/download/dsu_server_psmove-macos)
32-
- [Linux](https://github.com/Swordmaster3214/PSMove-DSU/releases/latest/download/dsu_server_psmove-linux)
30+
- [Windows](https://github.com/Swordmaster3214/PSMove-DSU/releases/latest/)
31+
- [macOS](https://github.com/Swordmaster3214/PSMove-DSU/releases/latest/)
32+
- [Linux](https://github.com/Swordmaster3214/PSMove-DSU/releases/latest/)
3333

34-
2. **Connect your PS Move controller** via USB or Bluetooth
34+
2. **Connect your PS Move controller** via Bluetooth
3535

3636
3. **Run the executable**:
37+
#### Windows
3738
```bash
38-
# Windows
39-
./dsu_server_psmove-windows-x64.exe
40-
41-
# macOS/Linux
42-
./dsu_server_psmove-macos
43-
./dsu_server_psmove-linux
39+
./dsu_server_psmove_windows_win64.exe
40+
```
41+
#### macOS/Linux
42+
```bash
43+
./dsu_server_psmove_macos_x64
44+
```
45+
```bash
46+
./dsu_server_psmove_linux_x64
4447
```
4548

46-
4. **Configure your emulator** to connect to `127.0.0.1:26760` (default DSU port)
49+
5. **Configure your emulator** to connect to `127.0.0.1:26760` (default DSU port)
4750

4851
### Button Mappings
4952

@@ -62,14 +65,10 @@ PS | PS
6265
### Controller Setup
6366

6467
#### Bluetooth Pairing
65-
**Note:** You will not need to do the following steps if you have already paired your controller with your computer using [PSMoveAPI](https://github.com/thp/psmoveapi)
66-
1. Connect the PS Move controller via USB first
67-
2. Use the auto-pairing utility in the program to pair via Bluetooth, note that it may require elevated permissions because it accesses your device's bluetooth stack
68-
69-
Once paired, disconnect the cable and power it on, a solid red light indicates that the controller can be used wirelessly
70-
71-
#### USB Connection
72-
Simply connect the PS Move controller via USB cable - it should be detected automatically.
68+
**Note:** You will not need to do the following if you have already paired your controller with your computer using [PSMoveAPI](https://github.com/thp/psmoveapi)
69+
```bash
70+
./dsu_server_psmove --pair
71+
```
7372

7473
## Building from Source
7574

@@ -78,7 +77,7 @@ Simply connect the PS Move controller via USB cable - it should be detected auto
7877
#### All Platforms
7978
- **CMake** 3.10 or higher
8079
- **C++ compiler** with C++17 support
81-
- **PSMoveAPI 4.0.12** (automatically downloaded by build process)
80+
- **PSMoveAPI 4.0.12** [downloaded](https://github.com/thp/psmoveapi/releases/latest/)
8281

8382
#### Linux
8483
```bash
@@ -98,33 +97,32 @@ brew install libusb
9897

9998
1. **Clone the repository**:
10099
```bash
101-
git clone https://github.com/Swordmaster3214/PSMove-DSU.git
102-
cd PSMove-DSU
100+
git clone https://github.com/Swordmaster3214/PSMove-DSU.git && cd PSMove-DSU
103101
```
104102

105103
2. **Create build directory**:
106104
```bash
107-
mkdir build
108-
cd build
105+
mkdir build && cd build
109106
```
110107

111108
3. **Configure with CMake**:
109+
#### Linux/macOS
112110
```bash
113-
# Linux/macOS
114-
cmake -DCMAKE_BUILD_TYPE=Release ..
115-
116-
# Windows
117-
cmake ..
111+
cmake -DCMAKE_BUILD_TYPE=Release -DPSMOVE_ROOT=/path/to/psmoveapi ..
112+
```
113+
#### Windows
114+
```bash
115+
cmake -DPSMOVE_ROOT=/path/to/psmoveapi ..
118116
```
119117

120-
4. **Build the project**:
118+
5. **Build the project**:
121119
```bash
122120
cmake --build . --config Release
123121
```
124122

125-
5. **Run the executable**:
123+
6. **Run the executable**:
124+
The executable will be in the build directory
126125
```bash
127-
# The executable will be in the build directory
128126
./dsu_server_psmove
129127
```
130128

@@ -135,7 +133,6 @@ If you have PSMoveAPI installed in a custom location:
135133
```bash
136134
cmake -DPSMOVE_ROOT=/path/to/psmoveapi ..
137135
```
138-
139136
## Configuration
140137

141138
### DSU Server Settings
@@ -158,7 +155,7 @@ The server runs on `127.0.0.1:26760` by default, which is the standard DSU port.
158155
## Troubleshooting
159156

160157
### Controller Not Detected
161-
- Ensure the PS Move controller is properly connected (USB) or paired (Bluetooth)
158+
- Ensure the PS Move controller is properly paired
162159
- On Linux, you may need to run with `sudo` for USB access permissions
163160
- Check that no other applications are using the controller
164161

@@ -174,11 +171,11 @@ The server runs on `127.0.0.1:26760` by default, which is the standard DSU port.
174171

175172
### Linux Permissions
176173
If you get permission errors accessing the controller:
174+
Add udev rules for PS Move controller
177175
```bash
178-
# Add udev rules for PS Move controller
179176
sudo usermod -a -G plugdev $USER
180-
# Log out and back in for changes to take effect
181177
```
178+
Log out and back in for changes to take effect
182179

183180
## Technical Details
184181

@@ -196,7 +193,7 @@ sudo usermod -a -G plugdev $USER
196193

197194
### Performance
198195
- **Low latency**: Direct USB/Bluetooth communication
199-
- **Single-controller**: Supports one PS Move controller
196+
- **Multi-controller**: Support in the project is implemented for multiple controllers, but only one seems to be working 😅
200197

201198
## Contributing
202199

@@ -221,9 +218,7 @@ Contributions are welcome! Please feel free to submit pull requests, report issu
221218
- **PSMoveAPI Documentation**: [psmoveapi.readthedocs.io](https://psmoveapi.readthedocs.io/)
222219
- **DSU Protocol**: [Cemuhook Documentation](https://cemuhook.sshnuke.net/)
223220

224-
---
225221

226-
**Note**: PlayStation Move controllers require initial USB connection for setup, even when using Bluetooth. Ensure your controllers are properly calibrated using PSMoveAPI tools before use.
227222

228223
## Licensing
229224
License details for this project are in the LICENSE file.

0 commit comments

Comments
 (0)