@@ -46,8 +46,10 @@ StaticVector<ControllerButtonEvent, 4> Joystick::ToControllerButtonEvents(const
46
46
return { ControllerButtonEvent { ControllerButton_BUTTON_RIGHTSTICK, up } };
47
47
#endif
48
48
#ifdef JOY_BUTTON_LEFTSHOULDER
49
- case JOY_BUTTON_LEFTSHOULDER:
49
+ case JOY_BUTTON_LEFTSHOULDER: {
50
+ Log (" ToControllerButtonEvents JOY_BUTTON_LEFTSHOULDER pressed" );
50
51
return { ControllerButtonEvent { ControllerButton_BUTTON_LEFTSHOULDER, up } };
52
+ }
51
53
#endif
52
54
#ifdef JOY_BUTTON_RIGHTSHOULDER
53
55
case JOY_BUTTON_RIGHTSHOULDER:
@@ -101,6 +103,20 @@ StaticVector<ControllerButtonEvent, 4> Joystick::ToControllerButtonEvents(const
101
103
}
102
104
case SDL_JOYAXISMOTION:
103
105
case SDL_JOYBALLMOTION:
106
+ #ifdef __DREAMCAST__
107
+ if (event.jaxis .axis == 3 ) {
108
+ Log (" BUTTON_LEFTSHOULDER detected" );
109
+ Log (" event.jbutton.button = {}" , event.jbutton .button );
110
+ Log (" event.jbutton.state == SDL_RELEASED = {}" , event.jbutton .state == SDL_RELEASED);
111
+ return { ControllerButtonEvent { ControllerButton_BUTTON_LEFTSHOULDER, event.jaxis .value < 255 } };
112
+ }
113
+ if (event.jaxis .axis == 2 ) {
114
+ Log (" BUTTON_RIGHTSHOULDER detected" );
115
+ Log (" event.jbutton.button = {}" , event.jbutton .button );
116
+ Log (" event.jbutton.state == SDL_RELEASED = {}" , event.jbutton .state == SDL_RELEASED);
117
+ return { ControllerButtonEvent { ControllerButton_BUTTON_RIGHTSHOULDER, event.jaxis .value < 255 } };
118
+ }
119
+ #endif
104
120
// ProcessAxisMotion() requires a ControllerButtonEvent parameter
105
121
// so provide one here using ControllerButton_NONE
106
122
return { ControllerButtonEvent { ControllerButton_NONE, false } };
@@ -211,8 +227,10 @@ int Joystick::ToSdlJoyButton(ControllerButton button)
211
227
return JOY_BUTTON_RIGHTSTICK;
212
228
#endif
213
229
#ifdef JOY_BUTTON_LEFTSHOULDER
214
- case ControllerButton_BUTTON_LEFTSHOULDER:
230
+ case ControllerButton_BUTTON_LEFTSHOULDER: {
231
+ Log (" ToSdlJoyButton JOY_BUTTON_LEFTSHOULDER pressed" );
215
232
return JOY_BUTTON_LEFTSHOULDER;
233
+ }
216
234
#endif
217
235
#ifdef JOY_BUTTON_RIGHTSHOULDER
218
236
case ControllerButton_BUTTON_RIGHTSHOULDER:
@@ -292,6 +310,31 @@ bool Joystick::IsPressed(ControllerButton button) const
292
310
return joyButton < numButtons && SDL_JoystickGetButton (sdl_joystick_, joyButton) != 0 ;
293
311
}
294
312
313
+ #ifdef __DREAMCAST__
314
+ bool Joystick::ProcessAxisMotion (const SDL_Event &event)
315
+ {
316
+ if (event.type != SDL_JOYAXISMOTION)
317
+ return false ;
318
+
319
+ Log (" ProcessAxisMotion event.jaxis.axis = {}" , event.jaxis .axis );
320
+ Log (" ProcessAxisMotion event.jaxis.value = {}" , event.jaxis .value );
321
+ Log (" ProcessAxisMotion event.jbutton.button = {}" , event.jbutton .button );
322
+ Log (" event.jbutton.state == SDL_RELEASED = {}" , event.jbutton .state == SDL_RELEASED);
323
+
324
+ switch (event.jaxis .axis ) {
325
+ case 0 : // horizontal
326
+ leftStickXUnscaled = event.jaxis .value ;
327
+ leftStickNeedsScaling = true ;
328
+ return true ;
329
+ case 1 : // vertical
330
+ leftStickYUnscaled = event.jaxis .value ;
331
+ leftStickNeedsScaling = true ;
332
+ return true ;
333
+ default :
334
+ return false ;
335
+ }
336
+ }
337
+ #else // !ifdef __DREAMCAST__
295
338
bool Joystick::ProcessAxisMotion (const SDL_Event &event)
296
339
{
297
340
if (event.type != SDL_JOYAXISMOTION)
@@ -330,6 +373,7 @@ bool Joystick::ProcessAxisMotion(const SDL_Event &event)
330
373
return false ;
331
374
#endif
332
375
}
376
+ #endif
333
377
334
378
void Joystick::Add (int deviceIndex)
335
379
{
0 commit comments