Skip to content

Commit 86cbb67

Browse files
committed
WIP raphnet PSX to USB support
1 parent 05a6423 commit 86cbb67

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#ifndef __DINPUT_RAPHNETPSX_H__
2+
#define __DINPUT_RAPHNETPSX_H__
3+
#include <psp2kern/ctrl.h>
4+
5+
uint8_t raphnetpsx_processReport(Controller *c, size_t length)
6+
{
7+
if (length >= 15)
8+
{
9+
// dpad
10+
if (bit(c->buffer + 14, 4))
11+
c->controlData.buttons |= SCE_CTRL_UP;
12+
if (bit(c->buffer + 14, 5))
13+
c->controlData.buttons |= SCE_CTRL_DOWN;
14+
if (bit(c->buffer + 14, 6))
15+
c->controlData.buttons |= SCE_CTRL_LEFT;
16+
if (bit(c->buffer + 14, 7))
17+
c->controlData.buttons |= SCE_CTRL_RIGHT;
18+
19+
if (bit(c->buffer + 13, 0))
20+
c->controlData.buttons |= SCE_CTRL_SQUARE;
21+
if (bit(c->buffer + 13, 1))
22+
c->controlData.buttons |= SCE_CTRL_CROSS;
23+
if (bit(c->buffer + 13, 2))
24+
c->controlData.buttons |= SCE_CTRL_CIRCLE;
25+
if (bit(c->buffer + 13, 3))
26+
c->controlData.buttons |= SCE_CTRL_TRIANGLE;
27+
28+
if (bit(c->buffer + 13, 4))
29+
c->controlData.buttons |= SCE_CTRL_START;
30+
if (bit(c->buffer + 13, 5))
31+
c->controlData.buttons |= SCE_CTRL_SELECT;
32+
33+
if (bit(c->buffer + 13, 6))
34+
c->controlData.buttons |= SCE_CTRL_L1;
35+
if (bit(c->buffer + 13, 7))
36+
c->controlData.buttons |= SCE_CTRL_R1;
37+
38+
if (bit(c->buffer + 14, 2))
39+
c->controlData.buttons |= SCE_CTRL_L3;
40+
if (bit(c->buffer + 14, 3))
41+
c->controlData.buttons |= SCE_CTRL_R3;
42+
43+
// triggers
44+
int16_t ltx = *(int16_t*)(c->buffer + 11);
45+
c->controlData.lt = ((int32_t)ltx - 16000) * 255 / 16000;
46+
int16_t rtx = *(int16_t*)(c->buffer + 9);
47+
c->controlData.rt = ((int32_t)rtx - 16000) * 255 / 16000;
48+
49+
// set buttons with little deadzone
50+
if (c->controlData.lt > 10)
51+
c->controlData.buttons |= SCE_CTRL_LTRIGGER;
52+
if (c->controlData.rt > 10)
53+
c->controlData.buttons |= SCE_CTRL_RTRIGGER;
54+
55+
if (bit(c->buffer + 14, 0))
56+
{
57+
c->controlData.buttons |= SCE_CTRL_LTRIGGER;
58+
c->controlData.lt = 0xFF;
59+
}
60+
if (bit(c->buffer + 14, 1))
61+
{
62+
c->controlData.buttons |= SCE_CTRL_RTRIGGER;
63+
c->controlData.rt = 0xFF;
64+
}
65+
66+
// axes
67+
int16_t lx = *(int16_t*)(c->buffer + 1);
68+
c->controlData.leftX = (int32_t)lx * 255 / 32000;
69+
int16_t ly = *(int16_t*)(c->buffer + 3);
70+
c->controlData.leftY = (int32_t)ly * 255 / 32000;
71+
72+
int16_t rx = *(int16_t*)(c->buffer + 5);
73+
c->controlData.rightX = (int32_t)rx * 255 / 32000;
74+
int16_t ry = *(int16_t*)(c->buffer + 7);
75+
c->controlData.rightY = (int32_t)ry * 255 / 32000;
76+
77+
if (bit(c->buffer + 13, 6) && bit(c->buffer + 13, 7) && bit(c->buffer + 13, 4)) // L+R+START combo
78+
{
79+
c->controlData.buttons |= SCE_CTRL_PSBUTTON;
80+
c->controlData.buttons &= ~SCE_CTRL_START;
81+
}
82+
}
83+
return 1;
84+
}
85+
86+
#endif

src/controllers/dinput_controller.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "dinput/logitech.h"
1010
#include "dinput/psclassic.h"
1111
#include "dinput/horidiva.h"
12+
#include "dinput/raphnetpsx.h"
1213

1314
uint8_t DinputController_probe(Controller *c, int device_id, int port, int vendor, int product)
1415
{
@@ -112,6 +113,10 @@ uint8_t DinputController_processReport(Controller *c, size_t length)
112113
{
113114
return logitech_processReport(c, length);
114115
}
116+
else if (c->vendor == 0x289b && c->product == 0x0044) // raphnet
117+
{
118+
return raphnetpsx_processReport(c, length);
119+
}
115120
else
116121
{
117122
return 0;

src/devicelist.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ gamepad_t _devices[] = {{PAD_XBOX360, 0x045e, 0x028e}, // Microsoft X-Box 360 p
106106
{PAD_DINPUT, 0x046d, 0xc218}, // Logitech F510 Gamepad [DirectInput Mode] / Rumblepad 2
107107
{PAD_DINPUT, 0x046d, 0xc216}, // Logitech F310 Gamepad [DirectInput Mode] / DualAction
108108
{PAD_DINPUT, 0x054c, 0x0cda}, // Playstation Classic
109-
{PAD_DINPUT, 0x0F0D, 0x0049}, // Hori ps3 mini diva
109+
{PAD_DINPUT, 0x0f0d, 0x0049}, // Hori ps3 mini diva
110+
{PAD_DINPUT, 0x289b, 0x0044}, // Raphnet Technologies PSX to USB v.1.0
110111

111112
{PAD_UNKNOWN, 0x0000, 0x0000}}; // Null

0 commit comments

Comments
 (0)