mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-01-26 03:00:55 +00:00
Merge branch 'gamepad-tweaks' into 'next'
Gamepad Improvements See merge request KartKrew/Kart-Public!5
This commit is contained in:
commit
e0f18f6d03
8 changed files with 1072 additions and 329 deletions
|
@ -304,7 +304,7 @@ typedef enum
|
||||||
SKINCOLOR_SLATE,
|
SKINCOLOR_SLATE,
|
||||||
SKINCOLOR_STEEL,
|
SKINCOLOR_STEEL,
|
||||||
SKINCOLOR_JET,
|
SKINCOLOR_JET,
|
||||||
SKINCOLOR_SAPPHIRE, // sweet mother, i cannot weave – slender aphrodite has overcome me with longing for a girl
|
SKINCOLOR_SAPPHIRE, // sweet mother, i cannot weave - slender aphrodite has overcome me with longing for a girl
|
||||||
SKINCOLOR_PERIWINKLE,
|
SKINCOLOR_PERIWINKLE,
|
||||||
SKINCOLOR_BLUE,
|
SKINCOLOR_BLUE,
|
||||||
SKINCOLOR_BLUEBERRY,
|
SKINCOLOR_BLUEBERRY,
|
||||||
|
|
|
@ -467,7 +467,7 @@ consvar_t cv_brakeaxis = {"joyaxis_brake", "None", CV_SAVE, joyaxis_cons_t, NULL
|
||||||
consvar_t cv_aimaxis = {"joyaxis_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_aimaxis = {"joyaxis_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_lookaxis = {"joyaxis_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_lookaxis = {"joyaxis_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_fireaxis = {"joyaxis_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_driftaxis = {"joyaxis_drift", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_driftaxis = {"joyaxis_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_turnaxis2 = {"joyaxis2_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_moveaxis2 = {"joyaxis2_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_moveaxis2 = {"joyaxis2_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
@ -475,7 +475,7 @@ consvar_t cv_brakeaxis2 = {"joyaxis2_brake", "None", CV_SAVE, joyaxis_cons_t, NU
|
||||||
consvar_t cv_aimaxis2 = {"joyaxis2_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_aimaxis2 = {"joyaxis2_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_lookaxis2 = {"joyaxis2_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_lookaxis2 = {"joyaxis2_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_fireaxis2 = {"joyaxis2_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_driftaxis2 = {"joyaxis2_drift", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_driftaxis2 = {"joyaxis2_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
consvar_t cv_turnaxis3 = {"joyaxis3_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_turnaxis3 = {"joyaxis3_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_moveaxis3 = {"joyaxis3_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_moveaxis3 = {"joyaxis3_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
@ -483,7 +483,7 @@ consvar_t cv_brakeaxis3 = {"joyaxis3_brake", "None", CV_SAVE, joyaxis_cons_t, NU
|
||||||
consvar_t cv_aimaxis3 = {"joyaxis3_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_aimaxis3 = {"joyaxis3_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_lookaxis3 = {"joyaxis3_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_lookaxis3 = {"joyaxis3_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_fireaxis3 = {"joyaxis3_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_fireaxis3 = {"joyaxis3_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_driftaxis3 = {"joyaxis3_drift", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_driftaxis3 = {"joyaxis3_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
consvar_t cv_turnaxis4 = {"joyaxis4_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_turnaxis4 = {"joyaxis4_turn", "X-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_moveaxis4 = {"joyaxis4_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_moveaxis4 = {"joyaxis4_move", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
@ -491,7 +491,7 @@ consvar_t cv_brakeaxis4 = {"joyaxis4_brake", "None", CV_SAVE, joyaxis_cons_t, NU
|
||||||
consvar_t cv_aimaxis4 = {"joyaxis4_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_aimaxis4 = {"joyaxis4_aim", "Y-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_lookaxis4 = {"joyaxis4_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_lookaxis4 = {"joyaxis4_look", "None", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_fireaxis4 = {"joyaxis4_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_fireaxis4 = {"joyaxis4_fire", "Z-Axis", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
consvar_t cv_driftaxis4 = {"joyaxis4_drift", "Z-Axis-", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
consvar_t cv_driftaxis4 = {"joyaxis4_drift", "Z-Rudder", CV_SAVE, joyaxis_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||||
|
|
||||||
|
|
||||||
#if MAXPLAYERS > 16
|
#if MAXPLAYERS > 16
|
||||||
|
|
|
@ -1328,10 +1328,10 @@ void G_Controldefault(UINT8 player)
|
||||||
gamecontrol[gc_viewpoint ][1] = KEY_JOY1+3; // Y
|
gamecontrol[gc_viewpoint ][1] = KEY_JOY1+3; // Y
|
||||||
gamecontrol[gc_pause ][1] = KEY_JOY1+6; // Back
|
gamecontrol[gc_pause ][1] = KEY_JOY1+6; // Back
|
||||||
gamecontrol[gc_systemmenu ][0] = KEY_JOY1+7; // Start
|
gamecontrol[gc_systemmenu ][0] = KEY_JOY1+7; // Start
|
||||||
gamecontrol[gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up
|
//gamecontrol[gc_camtoggle ][1] = KEY_HAT1+0; // D-Pad Up
|
||||||
gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down
|
//gamecontrol[gc_screenshot ][1] = KEY_HAT1+1; // D-Pad Down // absolutely fucking NOT
|
||||||
gamecontrol[gc_talkkey ][1] = KEY_HAT1+2; // D-Pad Left
|
gamecontrol[gc_talkkey ][1] = KEY_HAT1+1; // D-Pad Down
|
||||||
gamecontrol[gc_scores ][1] = KEY_HAT1+3; // D-Pad Right
|
gamecontrol[gc_scores ][1] = KEY_HAT1+0; // D-Pad Up
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player == 0 || player == 2)
|
if (player == 0 || player == 2)
|
||||||
|
|
273
src/m_menu.c
273
src/m_menu.c
|
@ -67,6 +67,13 @@
|
||||||
// And just some randomness for the exits.
|
// And just some randomness for the exits.
|
||||||
#include "m_random.h"
|
#include "m_random.h"
|
||||||
|
|
||||||
|
#if defined(HAVE_SDL)
|
||||||
|
#include "SDL.h"
|
||||||
|
#if SDL_VERSION_ATLEAST(2,0,0)
|
||||||
|
#include "sdl/sdlmain.h" // JOYSTICK_HOTPLUG
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef PC_DOS
|
#ifdef PC_DOS
|
||||||
#include <stdio.h> // for snprintf
|
#include <stdio.h> // for snprintf
|
||||||
int snprintf(char *str, size_t n, const char *fmt, ...);
|
int snprintf(char *str, size_t n, const char *fmt, ...);
|
||||||
|
@ -2465,44 +2472,42 @@ boolean M_Responder(event_t *ev)
|
||||||
// (but still allow shift keyup so caps doesn't get stuck)
|
// (but still allow shift keyup so caps doesn't get stuck)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (ev->type == ev_keydown)
|
||||||
|
{
|
||||||
|
ch = ev->data1;
|
||||||
|
|
||||||
|
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
|
||||||
|
switch (ch)
|
||||||
|
{
|
||||||
|
case KEY_MOUSE1:
|
||||||
|
//case KEY_JOY1:
|
||||||
|
//case KEY_JOY1 + 2:
|
||||||
|
ch = KEY_ENTER;
|
||||||
|
break;
|
||||||
|
/*case KEY_JOY1 + 3: // Brake can function as 'n' for message boxes now.
|
||||||
|
ch = 'n';
|
||||||
|
break;*/
|
||||||
|
case KEY_MOUSE1 + 1:
|
||||||
|
//case KEY_JOY1 + 1:
|
||||||
|
ch = KEY_BACKSPACE;
|
||||||
|
break;
|
||||||
|
case KEY_HAT1:
|
||||||
|
ch = KEY_UPARROW;
|
||||||
|
break;
|
||||||
|
case KEY_HAT1 + 1:
|
||||||
|
ch = KEY_DOWNARROW;
|
||||||
|
break;
|
||||||
|
case KEY_HAT1 + 2:
|
||||||
|
ch = KEY_LEFTARROW;
|
||||||
|
break;
|
||||||
|
case KEY_HAT1 + 3:
|
||||||
|
ch = KEY_RIGHTARROW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (menuactive)
|
else if (menuactive)
|
||||||
{
|
{
|
||||||
if (ev->type == ev_keydown)
|
if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime())
|
||||||
{
|
|
||||||
ch = ev->data1;
|
|
||||||
|
|
||||||
// added 5-2-98 remap virtual keys (mouse & joystick buttons)
|
|
||||||
switch (ch)
|
|
||||||
{
|
|
||||||
case KEY_MOUSE1:
|
|
||||||
case KEY_JOY1:
|
|
||||||
ch = KEY_ENTER;
|
|
||||||
break;
|
|
||||||
case KEY_JOY1 + 3:
|
|
||||||
ch = 'n';
|
|
||||||
break;
|
|
||||||
case KEY_MOUSE1 + 1:
|
|
||||||
case KEY_JOY1 + 1:
|
|
||||||
ch = KEY_ESCAPE;
|
|
||||||
break;
|
|
||||||
case KEY_JOY1 + 2:
|
|
||||||
ch = KEY_BACKSPACE;
|
|
||||||
break;
|
|
||||||
case KEY_HAT1:
|
|
||||||
ch = KEY_UPARROW;
|
|
||||||
break;
|
|
||||||
case KEY_HAT1 + 1:
|
|
||||||
ch = KEY_DOWNARROW;
|
|
||||||
break;
|
|
||||||
case KEY_HAT1 + 2:
|
|
||||||
ch = KEY_LEFTARROW;
|
|
||||||
break;
|
|
||||||
case KEY_HAT1 + 3:
|
|
||||||
ch = KEY_RIGHTARROW;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (ev->type == ev_joystick && ev->data1 == 0 && joywait < I_GetTime())
|
|
||||||
{
|
{
|
||||||
const INT32 jdeadzone = JOYAXISRANGE/4;
|
const INT32 jdeadzone = JOYAXISRANGE/4;
|
||||||
if (ev->data3 != INT32_MAX)
|
if (ev->data3 != INT32_MAX)
|
||||||
|
@ -2583,6 +2588,8 @@ boolean M_Responder(event_t *ev)
|
||||||
return false;
|
return false;
|
||||||
else if (ch == gamecontrol[gc_systemmenu][0] || ch == gamecontrol[gc_systemmenu][1]) // allow remappable ESC key
|
else if (ch == gamecontrol[gc_systemmenu][0] || ch == gamecontrol[gc_systemmenu][1]) // allow remappable ESC key
|
||||||
ch = KEY_ESCAPE;
|
ch = KEY_ESCAPE;
|
||||||
|
else if (ch == gamecontrol[gc_accelerate][0] || ch == gamecontrol[gc_accelerate][1])
|
||||||
|
ch = KEY_ENTER;
|
||||||
|
|
||||||
// F-Keys
|
// F-Keys
|
||||||
if (!menuactive)
|
if (!menuactive)
|
||||||
|
@ -2659,6 +2666,9 @@ boolean M_Responder(event_t *ev)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ch == gamecontrol[gc_brake][0] || ch == gamecontrol[gc_brake][1]) // do this here, otherwise brake opens the menu mid-game
|
||||||
|
ch = KEY_ESCAPE;
|
||||||
|
|
||||||
routine = currentMenu->menuitems[itemOn].itemaction;
|
routine = currentMenu->menuitems[itemOn].itemaction;
|
||||||
|
|
||||||
// Handle menuitems which need a specific key handling
|
// Handle menuitems which need a specific key handling
|
||||||
|
@ -2793,6 +2803,7 @@ boolean M_Responder(event_t *ev)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case KEY_ESCAPE:
|
case KEY_ESCAPE:
|
||||||
|
//case KEY_JOY1 + 2:
|
||||||
noFurtherInput = true;
|
noFurtherInput = true;
|
||||||
currentMenu->lastOn = itemOn;
|
currentMenu->lastOn = itemOn;
|
||||||
if (currentMenu->prevMenu)
|
if (currentMenu->prevMenu)
|
||||||
|
@ -8564,7 +8575,7 @@ static void M_ScreenshotOptions(INT32 choice)
|
||||||
|
|
||||||
static void M_DrawJoystick(void)
|
static void M_DrawJoystick(void)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i, compareval4, compareval3, compareval2, compareval;
|
||||||
|
|
||||||
M_DrawGenericMenu();
|
M_DrawGenericMenu();
|
||||||
|
|
||||||
|
@ -8573,17 +8584,44 @@ static void M_DrawJoystick(void)
|
||||||
M_DrawTextBox(OP_JoystickSetDef.x-8, OP_JoystickSetDef.y+LINEHEIGHT*i-12, 28, 1);
|
M_DrawTextBox(OP_JoystickSetDef.x-8, OP_JoystickSetDef.y+LINEHEIGHT*i-12, 28, 1);
|
||||||
//M_DrawSaveLoadBorder(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i);
|
//M_DrawSaveLoadBorder(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i);
|
||||||
|
|
||||||
if ((setupcontrolplayer == 4 && (i == cv_usejoystick4.value))
|
#ifdef JOYSTICK_HOTPLUG
|
||||||
|| (setupcontrolplayer == 3 && (i == cv_usejoystick3.value))
|
if (atoi(cv_usejoystick4.string) > I_NumJoys())
|
||||||
|| (setupcontrolplayer == 2 && (i == cv_usejoystick2.value))
|
compareval4 = atoi(cv_usejoystick4.string);
|
||||||
|| (setupcontrolplayer == 1 && (i == cv_usejoystick.value)))
|
else
|
||||||
V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i-4,recommendedflags,joystickInfo[i]);
|
compareval4 = cv_usejoystick4.value;
|
||||||
|
|
||||||
|
if (atoi(cv_usejoystick3.string) > I_NumJoys())
|
||||||
|
compareval3 = atoi(cv_usejoystick3.string);
|
||||||
|
else
|
||||||
|
compareval3 = cv_usejoystick3.value;
|
||||||
|
|
||||||
|
if (atoi(cv_usejoystick2.string) > I_NumJoys())
|
||||||
|
compareval2 = atoi(cv_usejoystick2.string);
|
||||||
|
else
|
||||||
|
compareval2 = cv_usejoystick2.value;
|
||||||
|
|
||||||
|
if (atoi(cv_usejoystick.string) > I_NumJoys())
|
||||||
|
compareval = atoi(cv_usejoystick.string);
|
||||||
|
else
|
||||||
|
compareval = cv_usejoystick.value;
|
||||||
|
#else
|
||||||
|
compareval4 = cv_usejoystick4.value;
|
||||||
|
compareval3 = cv_usejoystick3.value;
|
||||||
|
compareval2 = cv_usejoystick2.value;
|
||||||
|
compareval = cv_usejoystick.value
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if ((setupcontrolplayer == 4 && (i == compareval4))
|
||||||
|
|| (setupcontrolplayer == 3 && (i == compareval3))
|
||||||
|
|| (setupcontrolplayer == 2 && (i == compareval2))
|
||||||
|
|| (setupcontrolplayer == 1 && (i == compareval)))
|
||||||
|
V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i-4,V_GREENMAP,joystickInfo[i]);
|
||||||
else
|
else
|
||||||
V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i-4,0,joystickInfo[i]);
|
V_DrawString(OP_JoystickSetDef.x, OP_JoystickSetDef.y+LINEHEIGHT*i-4,0,joystickInfo[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_SetupJoystickMenu(INT32 choice)
|
void M_SetupJoystickMenu(INT32 choice)
|
||||||
{
|
{
|
||||||
INT32 i = 0;
|
INT32 i = 0;
|
||||||
const char *joyNA = "Unavailable";
|
const char *joyNA = "Unavailable";
|
||||||
|
@ -8598,6 +8636,25 @@ static void M_SetupJoystickMenu(INT32 choice)
|
||||||
strncpy(joystickInfo[i], I_GetJoyName(i), 28);
|
strncpy(joystickInfo[i], I_GetJoyName(i), 28);
|
||||||
else
|
else
|
||||||
strcpy(joystickInfo[i], joyNA);
|
strcpy(joystickInfo[i], joyNA);
|
||||||
|
|
||||||
|
#ifdef JOYSTICK_HOTPLUG
|
||||||
|
// We use cv_usejoystick.string as the USER-SET var
|
||||||
|
// and cv_usejoystick.value as the INTERNAL var
|
||||||
|
//
|
||||||
|
// In practice, if cv_usejoystick.string == 0, this overrides
|
||||||
|
// cv_usejoystick.value and always disables
|
||||||
|
//
|
||||||
|
// Update cv_usejoystick.string here so that the user can
|
||||||
|
// properly change this value.
|
||||||
|
if (i == cv_usejoystick.value)
|
||||||
|
CV_SetValue(&cv_usejoystick, i);
|
||||||
|
if (i == cv_usejoystick2.value)
|
||||||
|
CV_SetValue(&cv_usejoystick2, i);
|
||||||
|
if (i == cv_usejoystick3.value)
|
||||||
|
CV_SetValue(&cv_usejoystick3, i);
|
||||||
|
if (i == cv_usejoystick4.value)
|
||||||
|
CV_SetValue(&cv_usejoystick4, i);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
M_SetupNextMenu(&OP_JoystickSetDef);
|
M_SetupNextMenu(&OP_JoystickSetDef);
|
||||||
|
@ -8626,21 +8683,147 @@ static void M_Setup3PJoystickMenu(INT32 choice)
|
||||||
|
|
||||||
static void M_Setup4PJoystickMenu(INT32 choice)
|
static void M_Setup4PJoystickMenu(INT32 choice)
|
||||||
{
|
{
|
||||||
setupcontrolplayer = 3;
|
setupcontrolplayer = 4;
|
||||||
OP_JoystickSetDef.prevMenu = &OP_Joystick4Def;
|
OP_JoystickSetDef.prevMenu = &OP_Joystick4Def;
|
||||||
M_SetupJoystickMenu(choice);
|
M_SetupJoystickMenu(choice);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M_AssignJoystick(INT32 choice)
|
static void M_AssignJoystick(INT32 choice)
|
||||||
{
|
{
|
||||||
|
#ifdef JOYSTICK_HOTPLUG
|
||||||
|
INT32 oldchoice, oldstringchoice;
|
||||||
|
INT32 numjoys = I_NumJoys();
|
||||||
|
|
||||||
|
if (setupcontrolplayer == 4)
|
||||||
|
{
|
||||||
|
oldchoice = oldstringchoice = atoi(cv_usejoystick4.string) > numjoys ? atoi(cv_usejoystick4.string) : cv_usejoystick4.value;
|
||||||
|
CV_SetValue(&cv_usejoystick4, choice);
|
||||||
|
|
||||||
|
// Just in case last-minute changes were made to cv_usejoystick.value,
|
||||||
|
// update the string too
|
||||||
|
// But don't do this if we're intentionally setting higher than numjoys
|
||||||
|
if (choice <= numjoys)
|
||||||
|
{
|
||||||
|
CV_SetValue(&cv_usejoystick4, cv_usejoystick4.value);
|
||||||
|
|
||||||
|
// reset this so the comparison is valid
|
||||||
|
if (oldchoice > numjoys)
|
||||||
|
oldchoice = cv_usejoystick4.value;
|
||||||
|
|
||||||
|
if (oldchoice != choice)
|
||||||
|
{
|
||||||
|
if (choice && oldstringchoice > numjoys) // if we did not select "None", we likely selected a used device
|
||||||
|
CV_SetValue(&cv_usejoystick4, (oldstringchoice > numjoys ? oldstringchoice : oldchoice));
|
||||||
|
|
||||||
|
if (oldstringchoice ==
|
||||||
|
(atoi(cv_usejoystick4.string) > numjoys ? atoi(cv_usejoystick4.string) : cv_usejoystick4.value))
|
||||||
|
M_StartMessage("This joystick is used by another\n"
|
||||||
|
"player. Reset the joystick\n"
|
||||||
|
"for that player first.\n\n"
|
||||||
|
"(Press a key)\n", NULL, MM_NOTHING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (setupcontrolplayer == 3)
|
||||||
|
{
|
||||||
|
oldchoice = oldstringchoice = atoi(cv_usejoystick3.string) > numjoys ? atoi(cv_usejoystick3.string) : cv_usejoystick3.value;
|
||||||
|
CV_SetValue(&cv_usejoystick3, choice);
|
||||||
|
|
||||||
|
// Just in case last-minute changes were made to cv_usejoystick.value,
|
||||||
|
// update the string too
|
||||||
|
// But don't do this if we're intentionally setting higher than numjoys
|
||||||
|
if (choice <= numjoys)
|
||||||
|
{
|
||||||
|
CV_SetValue(&cv_usejoystick3, cv_usejoystick3.value);
|
||||||
|
|
||||||
|
// reset this so the comparison is valid
|
||||||
|
if (oldchoice > numjoys)
|
||||||
|
oldchoice = cv_usejoystick3.value;
|
||||||
|
|
||||||
|
if (oldchoice != choice)
|
||||||
|
{
|
||||||
|
if (choice && oldstringchoice > numjoys) // if we did not select "None", we likely selected a used device
|
||||||
|
CV_SetValue(&cv_usejoystick3, (oldstringchoice > numjoys ? oldstringchoice : oldchoice));
|
||||||
|
|
||||||
|
if (oldstringchoice ==
|
||||||
|
(atoi(cv_usejoystick3.string) > numjoys ? atoi(cv_usejoystick3.string) : cv_usejoystick3.value))
|
||||||
|
M_StartMessage("This joystick is used by another\n"
|
||||||
|
"player. Reset the joystick\n"
|
||||||
|
"for that player first.\n\n"
|
||||||
|
"(Press a key)\n", NULL, MM_NOTHING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (setupcontrolplayer == 2)
|
||||||
|
{
|
||||||
|
oldchoice = oldstringchoice = atoi(cv_usejoystick2.string) > numjoys ? atoi(cv_usejoystick2.string) : cv_usejoystick2.value;
|
||||||
|
CV_SetValue(&cv_usejoystick2, choice);
|
||||||
|
|
||||||
|
// Just in case last-minute changes were made to cv_usejoystick.value,
|
||||||
|
// update the string too
|
||||||
|
// But don't do this if we're intentionally setting higher than numjoys
|
||||||
|
if (choice <= numjoys)
|
||||||
|
{
|
||||||
|
CV_SetValue(&cv_usejoystick2, cv_usejoystick2.value);
|
||||||
|
|
||||||
|
// reset this so the comparison is valid
|
||||||
|
if (oldchoice > numjoys)
|
||||||
|
oldchoice = cv_usejoystick2.value;
|
||||||
|
|
||||||
|
if (oldchoice != choice)
|
||||||
|
{
|
||||||
|
if (choice && oldstringchoice > numjoys) // if we did not select "None", we likely selected a used device
|
||||||
|
CV_SetValue(&cv_usejoystick2, (oldstringchoice > numjoys ? oldstringchoice : oldchoice));
|
||||||
|
|
||||||
|
if (oldstringchoice ==
|
||||||
|
(atoi(cv_usejoystick2.string) > numjoys ? atoi(cv_usejoystick2.string) : cv_usejoystick2.value))
|
||||||
|
M_StartMessage("This joystick is used by another\n"
|
||||||
|
"player. Reset the joystick\n"
|
||||||
|
"for that player first.\n\n"
|
||||||
|
"(Press a key)\n", NULL, MM_NOTHING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (setupcontrolplayer == 1)
|
||||||
|
{
|
||||||
|
oldchoice = oldstringchoice = atoi(cv_usejoystick.string) > numjoys ? atoi(cv_usejoystick.string) : cv_usejoystick.value;
|
||||||
|
CV_SetValue(&cv_usejoystick, choice);
|
||||||
|
|
||||||
|
// Just in case last-minute changes were made to cv_usejoystick.value,
|
||||||
|
// update the string too
|
||||||
|
// But don't do this if we're intentionally setting higher than numjoys
|
||||||
|
if (choice <= numjoys)
|
||||||
|
{
|
||||||
|
CV_SetValue(&cv_usejoystick, cv_usejoystick.value);
|
||||||
|
|
||||||
|
// reset this so the comparison is valid
|
||||||
|
if (oldchoice > numjoys)
|
||||||
|
oldchoice = cv_usejoystick.value;
|
||||||
|
|
||||||
|
if (oldchoice != choice)
|
||||||
|
{
|
||||||
|
if (choice && oldstringchoice > numjoys) // if we did not select "None", we likely selected a used device
|
||||||
|
CV_SetValue(&cv_usejoystick, (oldstringchoice > numjoys ? oldstringchoice : oldchoice));
|
||||||
|
|
||||||
|
if (oldstringchoice ==
|
||||||
|
(atoi(cv_usejoystick.string) > numjoys ? atoi(cv_usejoystick.string) : cv_usejoystick.value))
|
||||||
|
M_StartMessage("This joystick is used by another\n"
|
||||||
|
"player. Reset the joystick\n"
|
||||||
|
"for that player first.\n\n"
|
||||||
|
"(Press a key)\n", NULL, MM_NOTHING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (setupcontrolplayer == 4)
|
if (setupcontrolplayer == 4)
|
||||||
CV_SetValue(&cv_usejoystick4, choice);
|
CV_SetValue(&cv_usejoystick4, choice);
|
||||||
else if (setupcontrolplayer == 3)
|
else if (setupcontrolplayer == 3)
|
||||||
CV_SetValue(&cv_usejoystick3, choice);
|
CV_SetValue(&cv_usejoystick3, choice);
|
||||||
else if (setupcontrolplayer == 2)
|
else if (setupcontrolplayer == 2)
|
||||||
CV_SetValue(&cv_usejoystick2, choice);
|
CV_SetValue(&cv_usejoystick2, choice);
|
||||||
else
|
else if (setupcontrolplayer == 1)
|
||||||
CV_SetValue(&cv_usejoystick, choice);
|
CV_SetValue(&cv_usejoystick, choice);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============
|
// =============
|
||||||
|
|
|
@ -69,7 +69,6 @@ void M_QuitResponse(INT32 ch);
|
||||||
// Determines whether to show a level in the list
|
// Determines whether to show a level in the list
|
||||||
boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt);
|
boolean M_CanShowLevelInList(INT32 mapnum, INT32 gt);
|
||||||
|
|
||||||
|
|
||||||
// flags for items in the menu
|
// flags for items in the menu
|
||||||
// menu handle (what we do when key is pressed
|
// menu handle (what we do when key is pressed
|
||||||
#define IT_TYPE 14 // (2+4+8)
|
#define IT_TYPE 14 // (2+4+8)
|
||||||
|
@ -173,6 +172,10 @@ extern menu_t *currentMenu;
|
||||||
extern menu_t MainDef;
|
extern menu_t MainDef;
|
||||||
extern menu_t SP_LoadDef;
|
extern menu_t SP_LoadDef;
|
||||||
|
|
||||||
|
// Call upon joystick hotplug
|
||||||
|
void M_SetupJoystickMenu(INT32 choice);
|
||||||
|
extern menu_t OP_JoystickSetDef;
|
||||||
|
|
||||||
// Stuff for customizing the player select screen
|
// Stuff for customizing the player select screen
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -72,6 +72,7 @@
|
||||||
#include "../console.h"
|
#include "../console.h"
|
||||||
#include "../command.h"
|
#include "../command.h"
|
||||||
#include "sdlmain.h"
|
#include "sdlmain.h"
|
||||||
|
#include "../i_system.h"
|
||||||
#ifdef HWRENDER
|
#ifdef HWRENDER
|
||||||
#include "../hardware/hw_main.h"
|
#include "../hardware/hw_main.h"
|
||||||
#include "../hardware/hw_drv.h"
|
#include "../hardware/hw_drv.h"
|
||||||
|
@ -951,6 +952,284 @@ void I_GetEvent(void)
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_JOYBUTTONDOWN:
|
||||||
Impl_HandleJoystickButtonEvent(evt.jbutton, evt.type);
|
Impl_HandleJoystickButtonEvent(evt.jbutton, evt.type);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
case SDL_JOYDEVICEADDED:
|
||||||
|
{
|
||||||
|
// OH BOY are you in for a good time! #abominationstation
|
||||||
|
|
||||||
|
SDL_Joystick *newjoy = SDL_JoystickOpen(evt.jdevice.which);
|
||||||
|
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick device index %d added\n", evt.jdevice.which + 1);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Because SDL's device index is unstable, we're going to cheat here a bit:
|
||||||
|
// For the first joystick setting that is NOT active:
|
||||||
|
//
|
||||||
|
// 1. Set cv_usejoystickX.value to the new device index (this does not change what is written to config.cfg)
|
||||||
|
//
|
||||||
|
// 2. Set OTHERS' cv_usejoystickX.value to THEIR new device index, because it likely changed
|
||||||
|
// * If device doesn't exist, switch cv_usejoystick back to default value (.string)
|
||||||
|
// * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value!
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// PLAYER 1
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
if (newjoy && (!JoyInfo.dev || !SDL_JoystickGetAttached(JoyInfo.dev))
|
||||||
|
&& JoyInfo2.dev != newjoy && JoyInfo3.dev != newjoy && JoyInfo4.dev != newjoy) // don't override a currently active device
|
||||||
|
{
|
||||||
|
cv_usejoystick.value = evt.jdevice.which + 1;
|
||||||
|
I_UpdateJoystickDeviceIndices(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// PLAYER 2
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
else if (newjoy && (!JoyInfo2.dev || !SDL_JoystickGetAttached(JoyInfo2.dev))
|
||||||
|
&& JoyInfo.dev != newjoy && JoyInfo3.dev != newjoy && JoyInfo4.dev != newjoy) // don't override a currently active device
|
||||||
|
{
|
||||||
|
cv_usejoystick2.value = evt.jdevice.which + 1;
|
||||||
|
I_UpdateJoystickDeviceIndices(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// PLAYER 3
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
else if (newjoy && (!JoyInfo3.dev || !SDL_JoystickGetAttached(JoyInfo3.dev))
|
||||||
|
&& JoyInfo.dev != newjoy && JoyInfo2.dev != newjoy && JoyInfo4.dev != newjoy) // don't override a currently active device
|
||||||
|
{
|
||||||
|
cv_usejoystick3.value = evt.jdevice.which + 1;
|
||||||
|
I_UpdateJoystickDeviceIndices(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////
|
||||||
|
// PLAYER 4
|
||||||
|
//////////////////////////////
|
||||||
|
|
||||||
|
else if (newjoy && (!JoyInfo4.dev || !SDL_JoystickGetAttached(JoyInfo4.dev))
|
||||||
|
&& JoyInfo.dev != newjoy && JoyInfo2.dev != newjoy && JoyInfo3.dev != newjoy) // don't override a currently active device
|
||||||
|
{
|
||||||
|
cv_usejoystick4.value = evt.jdevice.which + 1;
|
||||||
|
I_UpdateJoystickDeviceIndices(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Was cv_usejoystick disabled in settings?
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
if (!strcmp(cv_usejoystick.string, "0") || !cv_usejoystick.value)
|
||||||
|
cv_usejoystick.value = 0;
|
||||||
|
else if (atoi(cv_usejoystick.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
|
&& cv_usejoystick.value) // update the cvar ONLY if a device exists
|
||||||
|
CV_SetValue(&cv_usejoystick, cv_usejoystick.value);
|
||||||
|
|
||||||
|
if (!strcmp(cv_usejoystick2.string, "0") || !cv_usejoystick2.value)
|
||||||
|
cv_usejoystick2.value = 0;
|
||||||
|
else if (atoi(cv_usejoystick2.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
|
&& cv_usejoystick2.value) // update the cvar ONLY if a device exists
|
||||||
|
CV_SetValue(&cv_usejoystick2, cv_usejoystick2.value);
|
||||||
|
|
||||||
|
if (!strcmp(cv_usejoystick3.string, "0") || !cv_usejoystick3.value)
|
||||||
|
cv_usejoystick3.value = 0;
|
||||||
|
else if (atoi(cv_usejoystick3.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
|
&& cv_usejoystick3.value) // update the cvar ONLY if a device exists
|
||||||
|
CV_SetValue(&cv_usejoystick3, cv_usejoystick3.value);
|
||||||
|
|
||||||
|
if (!strcmp(cv_usejoystick4.string, "0") || !cv_usejoystick4.value)
|
||||||
|
cv_usejoystick4.value = 0;
|
||||||
|
else if (atoi(cv_usejoystick4.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
|
&& cv_usejoystick4.value) // update the cvar ONLY if a device exists
|
||||||
|
CV_SetValue(&cv_usejoystick4, cv_usejoystick4.value);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Update all joysticks' init states
|
||||||
|
// This is a little wasteful since cv_usejoystick already calls this, but
|
||||||
|
// we need to do this in case CV_SetValue did nothing because the string was already same.
|
||||||
|
// if the device is already active, this should do nothing, effectively.
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
I_InitJoystick();
|
||||||
|
I_InitJoystick2();
|
||||||
|
I_InitJoystick3();
|
||||||
|
I_InitJoystick4();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device index: %d\n", JoyInfo.oldjoy);
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick2 device index: %d\n", JoyInfo2.oldjoy);
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick3 device index: %d\n", JoyInfo3.oldjoy);
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick4 device index: %d\n", JoyInfo4.oldjoy);
|
||||||
|
|
||||||
|
// update the menu
|
||||||
|
if (currentMenu == &OP_JoystickSetDef)
|
||||||
|
M_SetupJoystickMenu(0);
|
||||||
|
|
||||||
|
if (JoyInfo.dev != newjoy && JoyInfo2.dev != newjoy && JoyInfo3.dev != newjoy && JoyInfo4.dev != newjoy)
|
||||||
|
SDL_JoystickClose(newjoy);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
case SDL_JOYDEVICEREMOVED:
|
||||||
|
if (JoyInfo.dev && !SDL_JoystickGetAttached(JoyInfo.dev))
|
||||||
|
{
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick1 removed, device index: %d\n", JoyInfo.oldjoy);
|
||||||
|
I_ShutdownJoystick();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JoyInfo2.dev && !SDL_JoystickGetAttached(JoyInfo2.dev))
|
||||||
|
{
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick2 removed, device index: %d\n", JoyInfo2.oldjoy);
|
||||||
|
I_ShutdownJoystick2();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JoyInfo3.dev && !SDL_JoystickGetAttached(JoyInfo3.dev))
|
||||||
|
{
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick3 removed, device index: %d\n", JoyInfo3.oldjoy);
|
||||||
|
I_ShutdownJoystick3();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JoyInfo4.dev && !SDL_JoystickGetAttached(JoyInfo4.dev))
|
||||||
|
{
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick4 removed, device index: %d\n", JoyInfo4.oldjoy);
|
||||||
|
I_ShutdownJoystick4();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Update the device indexes, because they likely changed
|
||||||
|
// * If device doesn't exist, switch cv_usejoystick back to default value (.string)
|
||||||
|
// * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value!
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
if (JoyInfo.dev)
|
||||||
|
cv_usejoystick.value = JoyInfo.oldjoy = I_GetJoystickDeviceIndex(JoyInfo.dev) + 1;
|
||||||
|
else if (atoi(cv_usejoystick.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick.string) != JoyInfo3.oldjoy
|
||||||
|
&& atoi(cv_usejoystick.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick.value = atoi(cv_usejoystick.string);
|
||||||
|
else if (atoi(cv_usejoystick2.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick2.string) != JoyInfo3.oldjoy
|
||||||
|
&& atoi(cv_usejoystick2.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick.value = atoi(cv_usejoystick2.string);
|
||||||
|
else if (atoi(cv_usejoystick3.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick3.string) != JoyInfo3.oldjoy
|
||||||
|
&& atoi(cv_usejoystick3.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick.value = atoi(cv_usejoystick3.string);
|
||||||
|
else if (atoi(cv_usejoystick4.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick4.string) != JoyInfo3.oldjoy
|
||||||
|
&& atoi(cv_usejoystick4.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick.value = atoi(cv_usejoystick4.string);
|
||||||
|
else // we tried...
|
||||||
|
cv_usejoystick.value = 0;
|
||||||
|
|
||||||
|
if (JoyInfo2.dev)
|
||||||
|
cv_usejoystick2.value = JoyInfo2.oldjoy = I_GetJoystickDeviceIndex(JoyInfo2.dev) + 1;
|
||||||
|
else if (atoi(cv_usejoystick.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick.string) != JoyInfo3.oldjoy
|
||||||
|
&& atoi(cv_usejoystick.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick2.value = atoi(cv_usejoystick.string);
|
||||||
|
else if (atoi(cv_usejoystick2.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick2.string) != JoyInfo3.oldjoy
|
||||||
|
&& atoi(cv_usejoystick2.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick2.value = atoi(cv_usejoystick2.string);
|
||||||
|
else if (atoi(cv_usejoystick3.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick3.string) != JoyInfo3.oldjoy
|
||||||
|
&& atoi(cv_usejoystick3.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick2.value = atoi(cv_usejoystick3.string);
|
||||||
|
else if (atoi(cv_usejoystick4.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick4.string) != JoyInfo3.oldjoy
|
||||||
|
&& atoi(cv_usejoystick4.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick2.value = atoi(cv_usejoystick4.string);
|
||||||
|
else // we tried...
|
||||||
|
cv_usejoystick2.value = 0;
|
||||||
|
|
||||||
|
if (JoyInfo3.dev)
|
||||||
|
cv_usejoystick3.value = JoyInfo3.oldjoy = I_GetJoystickDeviceIndex(JoyInfo3.dev) + 1;
|
||||||
|
else if (atoi(cv_usejoystick.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick3.value = atoi(cv_usejoystick.string);
|
||||||
|
else if (atoi(cv_usejoystick2.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick2.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick2.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick3.value = atoi(cv_usejoystick2.string);
|
||||||
|
else if (atoi(cv_usejoystick3.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick3.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick3.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick3.value = atoi(cv_usejoystick3.string);
|
||||||
|
else if (atoi(cv_usejoystick4.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick4.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick4.string) != JoyInfo4.oldjoy)
|
||||||
|
cv_usejoystick3.value = atoi(cv_usejoystick4.string);
|
||||||
|
else // we tried...
|
||||||
|
cv_usejoystick3.value = 0;
|
||||||
|
|
||||||
|
if (JoyInfo4.dev)
|
||||||
|
cv_usejoystick4.value = JoyInfo4.oldjoy = I_GetJoystickDeviceIndex(JoyInfo4.dev) + 1;
|
||||||
|
else if (atoi(cv_usejoystick.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick.string) != JoyInfo3.oldjoy)
|
||||||
|
cv_usejoystick4.value = atoi(cv_usejoystick.string);
|
||||||
|
else if (atoi(cv_usejoystick2.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick2.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick2.string) != JoyInfo3.oldjoy)
|
||||||
|
cv_usejoystick4.value = atoi(cv_usejoystick2.string);
|
||||||
|
else if (atoi(cv_usejoystick3.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick3.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick3.string) != JoyInfo3.oldjoy)
|
||||||
|
cv_usejoystick4.value = atoi(cv_usejoystick3.string);
|
||||||
|
else if (atoi(cv_usejoystick4.string) != JoyInfo.oldjoy
|
||||||
|
&& atoi(cv_usejoystick4.string) != JoyInfo2.oldjoy
|
||||||
|
&& atoi(cv_usejoystick4.string) != JoyInfo3.oldjoy)
|
||||||
|
cv_usejoystick4.value = atoi(cv_usejoystick4.string);
|
||||||
|
else // we tried...
|
||||||
|
cv_usejoystick4.value = 0;
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
// Was cv_usejoystick disabled in settings?
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
if (!strcmp(cv_usejoystick.string, "0"))
|
||||||
|
cv_usejoystick.value = 0;
|
||||||
|
else if (atoi(cv_usejoystick.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
|
&& cv_usejoystick.value) // update the cvar ONLY if a device exists
|
||||||
|
CV_SetValue(&cv_usejoystick, cv_usejoystick.value);
|
||||||
|
|
||||||
|
if (!strcmp(cv_usejoystick2.string, "0"))
|
||||||
|
cv_usejoystick2.value = 0;
|
||||||
|
else if (atoi(cv_usejoystick2.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
|
&& cv_usejoystick2.value) // update the cvar ONLY if a device exists
|
||||||
|
CV_SetValue(&cv_usejoystick2, cv_usejoystick2.value);
|
||||||
|
|
||||||
|
if (!strcmp(cv_usejoystick3.string, "0"))
|
||||||
|
cv_usejoystick3.value = 0;
|
||||||
|
else if (atoi(cv_usejoystick3.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
|
&& cv_usejoystick3.value) // update the cvar ONLY if a device exists
|
||||||
|
CV_SetValue(&cv_usejoystick3, cv_usejoystick3.value);
|
||||||
|
|
||||||
|
if (!strcmp(cv_usejoystick4.string, "0"))
|
||||||
|
cv_usejoystick4.value = 0;
|
||||||
|
else if (atoi(cv_usejoystick4.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
|
&& cv_usejoystick4.value) // update the cvar ONLY if a device exists
|
||||||
|
CV_SetValue(&cv_usejoystick4, cv_usejoystick4.value);
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device index: %d\n", JoyInfo.oldjoy);
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick2 device index: %d\n", JoyInfo2.oldjoy);
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick3 device index: %d\n", JoyInfo3.oldjoy);
|
||||||
|
CONS_Debug(DBG_GAMELOGIC, "Joystick4 device index: %d\n", JoyInfo4.oldjoy);
|
||||||
|
|
||||||
|
// update the menu
|
||||||
|
if (currentMenu == &OP_JoystickSetDef)
|
||||||
|
M_SetupJoystickMenu(0);
|
||||||
|
break;
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
I_Quit();
|
I_Quit();
|
||||||
M_QuitResponse('y');
|
M_QuitResponse('y');
|
||||||
|
|
|
@ -31,6 +31,9 @@ extern SDL_bool framebuffer;
|
||||||
#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
|
#define SDL2STUB() CONS_Printf("SDL2: stubbed: %s:%d\n", __func__, __LINE__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// So m_menu knows whether to store cv_usejoystick value or string
|
||||||
|
#define JOYSTICK_HOTPLUG
|
||||||
|
|
||||||
/** \brief The JoyInfo_s struct
|
/** \brief The JoyInfo_s struct
|
||||||
|
|
||||||
info about joystick
|
info about joystick
|
||||||
|
@ -77,6 +80,20 @@ extern SDLJoyInfo_t JoyInfo4;
|
||||||
|
|
||||||
void I_GetConsoleEvents(void);
|
void I_GetConsoleEvents(void);
|
||||||
|
|
||||||
|
// So we can call this from i_video event loop
|
||||||
|
void I_ShutdownJoystick(void);
|
||||||
|
void I_ShutdownJoystick2(void);
|
||||||
|
void I_ShutdownJoystick3(void);
|
||||||
|
void I_ShutdownJoystick4(void);
|
||||||
|
|
||||||
|
// Cheat to get the device index for a joystick handle
|
||||||
|
INT32 I_GetJoystickDeviceIndex(SDL_Joystick *dev);
|
||||||
|
|
||||||
|
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
|
||||||
|
void I_UpdateJoystickDeviceIndices(INT32 player);
|
||||||
|
|
||||||
|
void I_GetConsoleEvents(void);
|
||||||
|
|
||||||
void SDLforceUngrabMouse(void);
|
void SDLforceUngrabMouse(void);
|
||||||
|
|
||||||
// Needed for some WIN32 functions
|
// Needed for some WIN32 functions
|
||||||
|
|
Loading…
Reference in a new issue