Skip to content

Commit 1c4a41d

Browse files
committed
ddr pad emulates joystick
1 parent 5d9fda7 commit 1c4a41d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/GameControllers.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@
1919

2020
#define INPUT_NOT_IMPLEMENTED ((unsigned)-1)
2121

22+
#define DDR_PAD_EMULATES_STICK
23+
2224
typedef struct {
2325
gpio_dev* device;
2426
uint32_t mask;
2527
uint32_t pinNumber;
2628
} PortData;
2729

30+
const uint16_t gcmaskDLeft = 0x100;
31+
const uint16_t gcmaskDRight = 0x200;
32+
const uint16_t gcmaskDDown = 0x400;
33+
const uint16_t gcmaskDUp = 0x800;
34+
const uint16_t gcmaskDPad = 0xF00;
35+
2836
typedef struct {
2937
uint16_t buttons;
3038
uint8_t joystickX;

src/gamecube.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,27 @@ bool GameCubeController::readWithRumble(GameControllerData_t* data, bool rumble)
9999
data->cY = 1023-rescale(gcData.cY);
100100
data->shoulderLeft = rescale(gcData.shoulderLeft);
101101
data->shoulderRight = rescale(gcData.shoulderRight);
102+
#ifdef DDR_PAD_EMULATES_STICK
103+
if (0 == (gcData.buttons & 0x20) && gcData.joystickX == 1 && gcData.joystickY == 1 && gcData.cX == 1 && gcData.cY == 1 &&
104+
gcData.shoulderLeft == 1 && gcData.shoulderRight == 1 && gcData.buttons ) {
105+
data->joystickX = 512;
106+
data->joystickY = 512;
107+
108+
if (gcData.buttons & gcmaskDLeft) {
109+
data->joystickX = 0;
110+
}
111+
else if (gcData.buttons & gcmaskDRight) {
112+
data->joystickX = 1023;
113+
}
114+
115+
if (gcData.buttons & gcmaskDUp) {
116+
data->joystickY = 0;
117+
}
118+
else if (gcData.buttons & gcmaskDDown) {
119+
data->joystickY = 1023;
120+
}
121+
}
122+
#endif
102123
return true;
103124
}
104125
else {

0 commit comments

Comments
 (0)