mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
Fix gamepad joystick handling
This commit is contained in:
parent
c49a5dd0cf
commit
746f112bf7
2 changed files with 10 additions and 46 deletions
|
|
@ -92,6 +92,7 @@ INT32 G_GetDevicePlayer(INT32 deviceID)
|
||||||
void G_MapEventsToControls(event_t *ev)
|
void G_MapEventsToControls(event_t *ev)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
|
boolean alternate = false;
|
||||||
|
|
||||||
if (ev->device >= 0 && ev->device < MAXDEVICES)
|
if (ev->device >= 0 && ev->device < MAXDEVICES)
|
||||||
{
|
{
|
||||||
|
|
@ -142,11 +143,6 @@ void G_MapEventsToControls(event_t *ev)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ev_mouse: // buttons are virtual keys
|
case ev_mouse: // buttons are virtual keys
|
||||||
if (menuactive)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// X axis
|
// X axis
|
||||||
if (ev->data2 < 0)
|
if (ev->data2 < 0)
|
||||||
{
|
{
|
||||||
|
|
@ -177,11 +173,6 @@ void G_MapEventsToControls(event_t *ev)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ev_joystick: // buttons are virtual keys
|
case ev_joystick: // buttons are virtual keys
|
||||||
if (menuactive)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ev->data1 >= JOYAXISSET)
|
if (ev->data1 >= JOYAXISSET)
|
||||||
{
|
{
|
||||||
#ifdef PARANOIA
|
#ifdef PARANOIA
|
||||||
|
|
@ -190,18 +181,13 @@ void G_MapEventsToControls(event_t *ev)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = ev->data1 * 4;
|
alternate = ev->data1 % 2;
|
||||||
|
i = (ev->data1 / 2) * 2;
|
||||||
if (ev->device == 0)
|
CONS_Printf("AXIS ID IS %d\n", i);
|
||||||
{
|
|
||||||
if (CON_Ready() || chat_on)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ev->data2 != INT32_MAX)
|
if (ev->data2 != INT32_MAX)
|
||||||
{
|
{
|
||||||
// X axis
|
if (alternate == true)
|
||||||
if (ev->data2 < 0)
|
|
||||||
{
|
{
|
||||||
// Left
|
// Left
|
||||||
gamekeydown[ev->device][KEY_AXIS1 + i] = abs(ev->data2);
|
gamekeydown[ev->device][KEY_AXIS1 + i] = abs(ev->data2);
|
||||||
|
|
@ -214,22 +200,10 @@ void G_MapEventsToControls(event_t *ev)
|
||||||
gamekeydown[ev->device][KEY_AXIS1 + i + 1] = abs(ev->data2);
|
gamekeydown[ev->device][KEY_AXIS1 + i + 1] = abs(ev->data2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (ev->data3 != INT32_MAX)
|
|
||||||
{
|
{
|
||||||
// Y axis
|
gamekeydown[ev->device][KEY_AXIS1 + i] = 0;
|
||||||
if (ev->data3 < 0)
|
gamekeydown[ev->device][KEY_AXIS1 + i + 1] = 0;
|
||||||
{
|
|
||||||
// Up
|
|
||||||
gamekeydown[ev->device][KEY_AXIS1 + i + 2] = abs(ev->data3);
|
|
||||||
gamekeydown[ev->device][KEY_AXIS1 + i + 3] = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Down
|
|
||||||
gamekeydown[ev->device][KEY_AXIS1 + i + 2] = 0;
|
|
||||||
gamekeydown[ev->device][KEY_AXIS1 + i + 3] = abs(ev->data3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -792,18 +792,8 @@ static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//vaule[sic]
|
event.data1 = evt.axis;
|
||||||
if (evt.axis%2)
|
event.data2 = SDLJoyAxis(evt.value, event.type, event.device);
|
||||||
{
|
|
||||||
event.data1 = evt.axis / 2;
|
|
||||||
event.data2 = SDLJoyAxis(evt.value, event.type, event.device);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
evt.axis--;
|
|
||||||
event.data1 = evt.axis / 2;
|
|
||||||
event.data3 = SDLJoyAxis(evt.value, event.type, event.device);
|
|
||||||
}
|
|
||||||
|
|
||||||
D_PostEvent(&event);
|
D_PostEvent(&event);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue