SDL joystick events now work while in menus

- DirectInput axes are now X first, Y second.
- Menu axes controls swapped/fixed.
- Added SDL DualShock3 buttons in menu actions.
- Fixed SDL mouse system cursor; it could appear in-game.
This commit is contained in:
Jaime Moreira 2020-08-27 16:17:54 -04:00 committed by Christoph Oelckers
parent 731c68e69e
commit fd4d600694
5 changed files with 17 additions and 13 deletions

View file

@ -75,6 +75,8 @@ enum EKeyCodes
KEY_JOY6,
KEY_JOY7,
KEY_JOY8,
KEY_JOY14 = KEY_FIRSTJOYBUTTON+13,
KEY_JOY15 = KEY_FIRSTJOYBUTTON+14,
KEY_LASTJOYBUTTON = 0x187,
KEY_JOYPOV1_UP = 0x188,
KEY_JOYPOV1_RIGHT = 0x189,

View file

@ -52,6 +52,7 @@ bool I_SetCursor(FGameTexture *cursorpic)
return false;
}
SDL_ShowCursor(SDL_DISABLE);
if (cursorSurface == NULL)
cursorSurface = SDL_CreateRGBSurface (0, 32, 32, 32, MAKEARGB(0,255,0,0), MAKEARGB(0,0,255,0), MAKEARGB(0,0,0,255), MAKEARGB(255,0,0,0));
@ -67,6 +68,7 @@ bool I_SetCursor(FGameTexture *cursorpic)
SDL_FreeCursor (cursor);
cursor = SDL_CreateColorCursor (cursorSurface, 0, 0);
SDL_SetCursor (cursor);
SDL_ShowCursor(SDL_ENABLE);
}
else
{

View file

@ -493,13 +493,10 @@ void MessagePump (const SDL_Event &sev)
case SDL_JOYBUTTONDOWN:
case SDL_JOYBUTTONUP:
if (!GUICapture)
{
event.type = sev.type == SDL_JOYBUTTONDOWN ? EV_KeyDown : EV_KeyUp;
event.data1 = KEY_FIRSTJOYBUTTON + sev.jbutton.button;
if(event.data1 != 0)
D_PostEvent(&event);
}
event.type = sev.type == SDL_JOYBUTTONDOWN ? EV_KeyDown : EV_KeyUp;
event.data1 = KEY_FIRSTJOYBUTTON + sev.jbutton.button;
if(event.data1 != 0)
D_PostEvent(&event);
break;
}
}

View file

@ -459,7 +459,7 @@ void FDInputJoystick::ProcessInput()
{
// Since we sorted the axes, we know that the first two are definitely X and Y.
// They are probably a single stick, so use angular position to determine buttons.
buttonstate = Joy_XYAxesToButtons(axisval, Axes[0].Value);
buttonstate = Joy_XYAxesToButtons(Axes[0].Value, axisval);
Joy_GenerateButtonEvents(info->ButtonValue, buttonstate, 4, KEY_JOYAXIS1PLUS);
}
info->ButtonValue = buttonstate;

View file

@ -588,16 +588,19 @@ bool M_Responder (event_t *ev)
switch (ch)
{
case KEY_JOY1:
case KEY_JOY3:
case KEY_JOY15:
case KEY_PAD_A:
mkey = MKEY_Enter;
break;
case KEY_JOY2:
case KEY_JOY14:
case KEY_PAD_B:
mkey = MKEY_Back;
break;
case KEY_JOY3:
case KEY_JOY4:
case KEY_PAD_X:
mkey = MKEY_Clear;
break;
@ -614,28 +617,28 @@ bool M_Responder (event_t *ev)
case KEY_PAD_DPAD_UP:
case KEY_PAD_LTHUMB_UP:
case KEY_JOYAXIS1MINUS:
case KEY_JOYAXIS2MINUS:
case KEY_JOYPOV1_UP:
mkey = MKEY_Up;
break;
case KEY_PAD_DPAD_DOWN:
case KEY_PAD_LTHUMB_DOWN:
case KEY_JOYAXIS1PLUS:
case KEY_JOYAXIS2PLUS:
case KEY_JOYPOV1_DOWN:
mkey = MKEY_Down;
break;
case KEY_PAD_DPAD_LEFT:
case KEY_PAD_LTHUMB_LEFT:
case KEY_JOYAXIS2MINUS:
case KEY_JOYAXIS1MINUS:
case KEY_JOYPOV1_LEFT:
mkey = MKEY_Left;
break;
case KEY_PAD_DPAD_RIGHT:
case KEY_PAD_LTHUMB_RIGHT:
case KEY_JOYAXIS2PLUS:
case KEY_JOYAXIS1PLUS:
case KEY_JOYPOV1_RIGHT:
mkey = MKEY_Right;
break;