mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-13 21:31:32 +00:00
some joystick fixes
Turns out P3/P4 controllers are broken (and still are)
This commit is contained in:
parent
c2db0ddca2
commit
0dfd7fc41e
8 changed files with 127 additions and 48 deletions
|
@ -276,9 +276,9 @@ consvar_t cv_usejoystick = {"use_joystick", "0", CV_SAVE|CV_CALL, usejoystick_co
|
|||
consvar_t cv_usejoystick2 = {"use_joystick2", "0", CV_SAVE|CV_CALL, usejoystick_cons_t,
|
||||
I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_usejoystick3 = {"use_joystick3", "0", CV_SAVE|CV_CALL, usejoystick_cons_t,
|
||||
I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL};
|
||||
I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL};
|
||||
consvar_t cv_usejoystick4 = {"use_joystick4", "0", CV_SAVE|CV_CALL, usejoystick_cons_t,
|
||||
I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL};
|
||||
I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL};
|
||||
#endif
|
||||
#if (defined (LJOYSTICK) || defined (HAVE_SDL))
|
||||
#ifdef LJOYSTICK
|
||||
|
|
58
src/g_game.c
58
src/g_game.c
|
@ -1006,8 +1006,8 @@ static INT32 Joy3Axis(axis_input_e axissel)
|
|||
}
|
||||
else
|
||||
#endif
|
||||
if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None
|
||||
return 0;
|
||||
if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None
|
||||
return 0;
|
||||
|
||||
if (axisval%2)
|
||||
{
|
||||
|
@ -1025,18 +1025,18 @@ static INT32 Joy3Axis(axis_input_e axissel)
|
|||
skipDC:
|
||||
#endif
|
||||
|
||||
if (retaxis < (-JOYAXISRANGE))
|
||||
retaxis = -JOYAXISRANGE;
|
||||
if (retaxis > (+JOYAXISRANGE))
|
||||
retaxis = +JOYAXISRANGE;
|
||||
if (!Joystick3.bGamepadStyle && axissel < AXISDEAD)
|
||||
{
|
||||
const INT32 jdeadzone = JOYAXISRANGE/4;
|
||||
if (-jdeadzone < retaxis && retaxis < jdeadzone)
|
||||
return 0;
|
||||
}
|
||||
if (flp) retaxis = -retaxis; //flip it around
|
||||
return retaxis;
|
||||
if (retaxis < (-JOYAXISRANGE))
|
||||
retaxis = -JOYAXISRANGE;
|
||||
if (retaxis > (+JOYAXISRANGE))
|
||||
retaxis = +JOYAXISRANGE;
|
||||
if (!Joystick3.bGamepadStyle && axissel < AXISDEAD)
|
||||
{
|
||||
const INT32 jdeadzone = JOYAXISRANGE/4;
|
||||
if (-jdeadzone < retaxis && retaxis < jdeadzone)
|
||||
return 0;
|
||||
}
|
||||
if (flp) retaxis = -retaxis; //flip it around
|
||||
return retaxis;
|
||||
}
|
||||
|
||||
static INT32 Joy4Axis(axis_input_e axissel)
|
||||
|
@ -1079,13 +1079,13 @@ static INT32 Joy4Axis(axis_input_e axissel)
|
|||
#ifdef _arch_dreamcast
|
||||
if (axisval == 7) // special case
|
||||
{
|
||||
retaxis = joy4xmove[1] - joy4ymove[1];
|
||||
retaxis = joy2xmove[1] - joy2ymove[1];
|
||||
goto skipDC;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None
|
||||
return 0;
|
||||
if (axisval > JOYAXISSET*2 || axisval == 0) //not there in array or None
|
||||
return 0;
|
||||
|
||||
if (axisval%2)
|
||||
{
|
||||
|
@ -1103,18 +1103,18 @@ static INT32 Joy4Axis(axis_input_e axissel)
|
|||
skipDC:
|
||||
#endif
|
||||
|
||||
if (retaxis < (-JOYAXISRANGE))
|
||||
retaxis = -JOYAXISRANGE;
|
||||
if (retaxis > (+JOYAXISRANGE))
|
||||
retaxis = +JOYAXISRANGE;
|
||||
if (!Joystick4.bGamepadStyle && axissel < AXISDEAD)
|
||||
{
|
||||
const INT32 jdeadzone = JOYAXISRANGE/4;
|
||||
if (-jdeadzone < retaxis && retaxis < jdeadzone)
|
||||
return 0;
|
||||
}
|
||||
if (flp) retaxis = -retaxis; //flip it around
|
||||
return retaxis;
|
||||
if (retaxis < (-JOYAXISRANGE))
|
||||
retaxis = -JOYAXISRANGE;
|
||||
if (retaxis > (+JOYAXISRANGE))
|
||||
retaxis = +JOYAXISRANGE;
|
||||
if (!Joystick4.bGamepadStyle && axissel < AXISDEAD)
|
||||
{
|
||||
const INT32 jdeadzone = JOYAXISRANGE/4;
|
||||
if (-jdeadzone < retaxis && retaxis < jdeadzone)
|
||||
return 0;
|
||||
}
|
||||
if (flp) retaxis = -retaxis; //flip it around
|
||||
return retaxis;
|
||||
}
|
||||
|
||||
static boolean InputDown(INT32 gc, UINT8 p)
|
||||
|
|
|
@ -2036,7 +2036,7 @@ void Command_Setcontrol3_f(void)
|
|||
|
||||
if (na != 3 && na != 4)
|
||||
{
|
||||
CONS_Printf(M_GetText("setcontrol23 <controlname> <keyname> [<2nd keyname>]: set controls for player 3\n"));
|
||||
CONS_Printf(M_GetText("setcontrol3 <controlname> <keyname> [<2nd keyname>]: set controls for player 3\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -330,6 +330,14 @@ void I_GetJoystickEvents(void);
|
|||
*/
|
||||
void I_GetJoystick2Events(void);
|
||||
|
||||
/** \brief Third Joystick's events
|
||||
*/
|
||||
void I_GetJoystick3Events(void);
|
||||
|
||||
/** \brief Fourth Joystick's events
|
||||
*/
|
||||
void I_GetJoystick4Events(void);
|
||||
|
||||
/** \brief Mouses events
|
||||
*/
|
||||
void I_GetMouseEvents(void);
|
||||
|
|
25
src/m_menu.c
25
src/m_menu.c
|
@ -7138,9 +7138,7 @@ static void M_SetupJoystickMenu(INT32 choice)
|
|||
|
||||
static void M_Setup1PJoystickMenu(INT32 choice)
|
||||
{
|
||||
setupcontrols_secondaryplayer = false;
|
||||
setupcontrols_thirdplayer = false;
|
||||
setupcontrols_fourthplayer = false;
|
||||
setupcontrols_secondaryplayer = setupcontrols_thirdplayer = setupcontrols_fourthplayer = false;
|
||||
OP_JoystickSetDef.prevMenu = &OP_Joystick1Def;
|
||||
M_SetupJoystickMenu(choice);
|
||||
}
|
||||
|
@ -7148,8 +7146,7 @@ static void M_Setup1PJoystickMenu(INT32 choice)
|
|||
static void M_Setup2PJoystickMenu(INT32 choice)
|
||||
{
|
||||
setupcontrols_secondaryplayer = true;
|
||||
setupcontrols_thirdplayer = false;
|
||||
setupcontrols_fourthplayer = false;
|
||||
setupcontrols_thirdplayer = setupcontrols_fourthplayer = false;
|
||||
OP_JoystickSetDef.prevMenu = &OP_Joystick2Def;
|
||||
M_SetupJoystickMenu(choice);
|
||||
}
|
||||
|
@ -7157,8 +7154,7 @@ static void M_Setup2PJoystickMenu(INT32 choice)
|
|||
static void M_Setup3PJoystickMenu(INT32 choice)
|
||||
{
|
||||
setupcontrols_thirdplayer = true;
|
||||
setupcontrols_secondaryplayer = false;
|
||||
setupcontrols_fourthplayer = false;
|
||||
setupcontrols_secondaryplayer = setupcontrols_fourthplayer = false;
|
||||
OP_JoystickSetDef.prevMenu = &OP_Joystick3Def;
|
||||
M_SetupJoystickMenu(choice);
|
||||
}
|
||||
|
@ -7166,15 +7162,18 @@ static void M_Setup3PJoystickMenu(INT32 choice)
|
|||
static void M_Setup4PJoystickMenu(INT32 choice)
|
||||
{
|
||||
setupcontrols_fourthplayer = true;
|
||||
setupcontrols_secondaryplayer = false;
|
||||
setupcontrols_thirdplayer = false;
|
||||
setupcontrols_secondaryplayer = setupcontrols_thirdplayer = false;
|
||||
OP_JoystickSetDef.prevMenu = &OP_Joystick4Def;
|
||||
M_SetupJoystickMenu(choice);
|
||||
}
|
||||
|
||||
static void M_AssignJoystick(INT32 choice)
|
||||
{
|
||||
if (setupcontrols_secondaryplayer)
|
||||
if (setupcontrols_fourthplayer)
|
||||
CV_SetValue(&cv_usejoystick4, choice);
|
||||
else if (setupcontrols_thirdplayer)
|
||||
CV_SetValue(&cv_usejoystick3, choice);
|
||||
else if (setupcontrols_secondaryplayer)
|
||||
CV_SetValue(&cv_usejoystick2, choice);
|
||||
else
|
||||
CV_SetValue(&cv_usejoystick, choice);
|
||||
|
@ -7187,9 +7186,7 @@ static void M_AssignJoystick(INT32 choice)
|
|||
static void M_Setup1PControlsMenu(INT32 choice)
|
||||
{
|
||||
(void)choice;
|
||||
setupcontrols_secondaryplayer = false;
|
||||
setupcontrols_thirdplayer = false;
|
||||
setupcontrols_fourthplayer = false;
|
||||
setupcontrols_secondaryplayer = setupcontrols_thirdplayer = setupcontrols_fourthplayer = false;
|
||||
setupcontrols = gamecontrol; // was called from main Options (for console player, then)
|
||||
currentMenu->lastOn = itemOn;
|
||||
|
||||
|
@ -7339,6 +7336,8 @@ static void M_ChangecontrolResponse(event_t *ev)
|
|||
case ev_mouse2:
|
||||
case ev_joystick:
|
||||
case ev_joystick2:
|
||||
case ev_joystick3:
|
||||
case ev_joystick4:
|
||||
ch = KEY_NULL; // no key
|
||||
break;
|
||||
|
||||
|
|
|
@ -2036,7 +2036,7 @@ void I_InitJoystick4(void)
|
|||
{
|
||||
I_ShutdownJoystick4();
|
||||
SDL_SetHintWithPriority("SDL_XINPUT_ENABLED", "0", SDL_HINT_OVERRIDE);
|
||||
if (!strcmp(cv_usejoystick3.string, "0") || M_CheckParm("-nojoy"))
|
||||
if (!strcmp(cv_usejoystick4.string, "0") || M_CheckParm("-nojoy"))
|
||||
return;
|
||||
if (joy_open4(cv_usejoystick4.string) != -1)
|
||||
JoyInfo4.oldjoy = atoi(cv_usejoystick4.string);
|
||||
|
|
|
@ -522,6 +522,48 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
|||
{
|
||||
raxis = JoyInfo2.scale!=1?((raxis/JoyInfo2.scale)*JoyInfo2.scale):raxis;
|
||||
|
||||
#ifdef SDL_JDEADZONE
|
||||
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
|
||||
raxis = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (which == ev_joystick3)
|
||||
{
|
||||
if (Joystick3.bGamepadStyle)
|
||||
{
|
||||
// gamepad control type, on or off, live or die
|
||||
if (raxis < -(JOYAXISRANGE/2))
|
||||
raxis = -1;
|
||||
else if (raxis > (JOYAXISRANGE/2))
|
||||
raxis = 1;
|
||||
else raxis = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
raxis = JoyInfo3.scale!=1?((raxis/JoyInfo3.scale)*JoyInfo3.scale):raxis;
|
||||
|
||||
#ifdef SDL_JDEADZONE
|
||||
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
|
||||
raxis = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else if (which == ev_joystick4)
|
||||
{
|
||||
if (Joystick4.bGamepadStyle)
|
||||
{
|
||||
// gamepad control type, on or off, live or die
|
||||
if (raxis < -(JOYAXISRANGE/2))
|
||||
raxis = -1;
|
||||
else if (raxis > (JOYAXISRANGE/2))
|
||||
raxis = 1;
|
||||
else raxis = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
raxis = JoyInfo4.scale!=1?((raxis/JoyInfo4.scale)*JoyInfo4.scale):raxis;
|
||||
|
||||
#ifdef SDL_JDEADZONE
|
||||
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
|
||||
raxis = 0;
|
||||
|
@ -717,11 +759,13 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
|
|||
static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
|
||||
{
|
||||
event_t event;
|
||||
SDL_JoystickID joyid[2];
|
||||
SDL_JoystickID joyid[4];
|
||||
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev);
|
||||
joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev);
|
||||
joyid[2] = SDL_JoystickInstanceID(JoyInfo3.dev);
|
||||
joyid[3] = SDL_JoystickInstanceID(JoyInfo4.dev);
|
||||
|
||||
evt.axis++;
|
||||
event.data1 = event.data2 = event.data3 = INT32_MAX;
|
||||
|
@ -734,6 +778,14 @@ static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
|
|||
{
|
||||
event.type = ev_joystick2;
|
||||
}
|
||||
else if (evt.which == joyid[2])
|
||||
{
|
||||
event.type = ev_joystick3;
|
||||
}
|
||||
else if (evt.which == joyid[3])
|
||||
{
|
||||
event.type = ev_joystick4;
|
||||
}
|
||||
else return;
|
||||
//axis
|
||||
if (evt.axis > JOYAXISSET*2)
|
||||
|
@ -756,11 +808,13 @@ static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
|
|||
static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
|
||||
{
|
||||
event_t event;
|
||||
SDL_JoystickID joyid[2];
|
||||
SDL_JoystickID joyid[4];
|
||||
|
||||
// Determine the Joystick IDs for each current open joystick
|
||||
joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev);
|
||||
joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev);
|
||||
joyid[2] = SDL_JoystickInstanceID(JoyInfo3.dev);
|
||||
joyid[3] = SDL_JoystickInstanceID(JoyInfo4.dev);
|
||||
|
||||
if (evt.which == joyid[0])
|
||||
{
|
||||
|
@ -770,6 +824,14 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
|
|||
{
|
||||
event.data1 = KEY_2JOY1;
|
||||
}
|
||||
else if (evt.which == joyid[2])
|
||||
{
|
||||
event.data1 = KEY_3JOY1;
|
||||
}
|
||||
else if (evt.which == joyid[3])
|
||||
{
|
||||
event.data1 = KEY_4JOY1;
|
||||
}
|
||||
else return;
|
||||
if (type == SDL_JOYBUTTONUP)
|
||||
{
|
||||
|
@ -891,6 +953,8 @@ void I_OsPolling(void)
|
|||
SDL_JoystickUpdate();
|
||||
I_GetJoystickEvents();
|
||||
I_GetJoystick2Events();
|
||||
I_GetJoystick3Events();
|
||||
I_GetJoystick4Events();
|
||||
}
|
||||
|
||||
I_GetMouseEvents();
|
||||
|
|
|
@ -67,6 +67,14 @@ extern SDLJoyInfo_t JoyInfo;
|
|||
*/
|
||||
extern SDLJoyInfo_t JoyInfo2;
|
||||
|
||||
/** \brief SDL inof about joystick 3
|
||||
*/
|
||||
extern SDLJoyInfo_t JoyInfo3;
|
||||
|
||||
/** \brief SDL inof about joystick 4
|
||||
*/
|
||||
extern SDLJoyInfo_t JoyInfo4;
|
||||
|
||||
void I_GetConsoleEvents(void);
|
||||
|
||||
void SDLforceUngrabMouse(void);
|
||||
|
|
Loading…
Reference in a new issue