SDL files

This commit is contained in:
Sally Coolatta 2020-08-15 06:02:39 -04:00
parent 9efdc98de6
commit f12501dfb6
5 changed files with 297 additions and 1850 deletions

View file

@ -184,9 +184,13 @@ void I_JoyScale4(void);
// Called by D_SRB2Main.
/** \brief to startup a joystick
*/
void I_InitJoystick(UINT8 index);
/** \brief to startup the first joystick
*/
void I_InitJoystick(void);
void I_InitJoystick1(void);
/** \brief to startup the second joystick
*/
@ -318,19 +322,7 @@ const char *I_LocateWad(void);
/** \brief First Joystick's events
*/
void I_GetJoystickEvents(void);
/** \brief Second Joystick's events
*/
void I_GetJoystick2Events(void);
/** \brief Third Joystick's events
*/
void I_GetJoystick3Events(void);
/** \brief Fourth Joystick's events
*/
void I_GetJoystick4Events(void);
void I_GetJoystickEvents(UINT8 index);
/** \brief Mouses events
*/

File diff suppressed because it is too large Load diff

View file

@ -528,7 +528,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
INT32 raxis = axis/32;
if (which == ev_joystick)
{
if (Joystick.bGamepadStyle)
if (Joystick[0].bGamepadStyle)
{
// gamepad control type, on or off, live or die
if (raxis < -(JOYAXISRANGE/2))
@ -540,7 +540,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
}
else
{
raxis = JoyInfo.scale!=1?((raxis/JoyInfo.scale)*JoyInfo.scale):raxis;
raxis = JoyInfo[0].scale!=1?((raxis/JoyInfo[0].scale)*JoyInfo[0].scale):raxis;
#ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
@ -550,7 +550,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
}
else if (which == ev_joystick2)
{
if (Joystick2.bGamepadStyle)
if (Joystick[1].bGamepadStyle)
{
// gamepad control type, on or off, live or die
if (raxis < -(JOYAXISRANGE/2))
@ -561,7 +561,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
}
else
{
raxis = JoyInfo2.scale!=1?((raxis/JoyInfo2.scale)*JoyInfo2.scale):raxis;
raxis = JoyInfo[1].scale!=1?((raxis/JoyInfo[1].scale)*JoyInfo[1].scale):raxis;
#ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
@ -571,7 +571,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
}
else if (which == ev_joystick3)
{
if (Joystick3.bGamepadStyle)
if (Joystick[2].bGamepadStyle)
{
// gamepad control type, on or off, live or die
if (raxis < -(JOYAXISRANGE/2))
@ -582,7 +582,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
}
else
{
raxis = JoyInfo3.scale!=1?((raxis/JoyInfo3.scale)*JoyInfo3.scale):raxis;
raxis = JoyInfo[2].scale!=1?((raxis/JoyInfo[2].scale)*JoyInfo[2].scale):raxis;
#ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
@ -592,7 +592,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
}
else if (which == ev_joystick4)
{
if (Joystick4.bGamepadStyle)
if (Joystick[3].bGamepadStyle)
{
// gamepad control type, on or off, live or die
if (raxis < -(JOYAXISRANGE/2))
@ -603,7 +603,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
}
else
{
raxis = JoyInfo4.scale!=1?((raxis/JoyInfo4.scale)*JoyInfo4.scale):raxis;
raxis = JoyInfo[3].scale!=1?((raxis/JoyInfo[3].scale)*JoyInfo[3].scale):raxis;
#ifdef SDL_JDEADZONE
if (-SDL_JDEADZONE <= raxis && raxis <= SDL_JDEADZONE)
@ -823,13 +823,12 @@ static void Impl_HandleMouseWheelEvent(SDL_MouseWheelEvent evt)
static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
{
event_t event;
SDL_JoystickID joyid[4];
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
UINT8 i;
// 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);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
evt.axis++;
event.data1 = event.data2 = event.data3 = INT32_MAX;
@ -873,11 +872,12 @@ static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
static void Impl_HandleJoystickHatEvent(SDL_JoyHatEvent evt)
{
event_t event;
SDL_JoystickID joyid[2];
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
UINT8 i;
// Determine the Joystick IDs for each current open joystick
joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev);
joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
if (evt.hat >= JOYHATS)
return; // ignore hats with too high an index
@ -890,6 +890,14 @@ static void Impl_HandleJoystickHatEvent(SDL_JoyHatEvent evt)
{
event.data1 = KEY_2HAT1 + (evt.hat*4);
}
else if (evt.which == joyid[2])
{
event.data1 = KEY_3HAT1 + (evt.hat*4);
}
else if (evt.which == joyid[3])
{
event.data1 = KEY_4HAT1 + (evt.hat*4);
}
else return;
// NOTE: UNFINISHED
@ -899,13 +907,12 @@ static void Impl_HandleJoystickHatEvent(SDL_JoyHatEvent evt)
static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
{
event_t event;
SDL_JoystickID joyid[4];
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
UINT8 i;
// 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);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
if (evt.which == joyid[0])
{
@ -948,10 +955,13 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
void I_GetEvent(void)
{
SDL_Event evt;
// We only want the first motion event,
// otherwise we'll end up catching the warp back to center.
//int mouseMotionOnce = 0;
UINT8 i;
if (!graphics_started)
{
return;
@ -1016,77 +1026,42 @@ void I_GetEvent(void)
// * 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
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
cv_usejoystick.value = evt.jdevice.which + 1;
I_UpdateJoystickDeviceIndices(1);
}
if (newjoy && (!JoyInfo[i].dev || !SDL_JoystickGetAttached(JoyInfo[i].dev)))
{
UINT8 j;
//////////////////////////////
// PLAYER 2
//////////////////////////////
for (j = 0; j < MAXSPLITSCREENPLAYERS; j++)
{
if (i == j)
continue;
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);
}
if (JoyInfo[j].dev == newjoy)
break;
}
//////////////////////////////
// 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);
if (j == MAXSPLITSCREENPLAYERS)
{
// ensures we aren't overriding a currently active device
cv_usejoystick[i].value = evt.jdevice.which + 1;
I_UpdateJoystickDeviceIndices(0);
}
}
}
////////////////////////////////////////////////////////////
// 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);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!strcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value)
cv_usejoystick[i].value = 0;
else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
&& cv_usejoystick[i].value) // update the cvar ONLY if a device exists
CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].value);
}
////////////////////////////////////////////////////////////
// Update all joysticks' init states
@ -1095,23 +1070,25 @@ void I_GetEvent(void)
// if the device is already active, this should do nothing, effectively.
////////////////////////////////////////////////////////////
I_InitJoystick();
I_InitJoystick2();
I_InitJoystick3();
I_InitJoystick4();
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
I_InitJoystick(i);
////////////////////////////////////////////////////////////
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);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy);
// update the menu
if (currentMenu == &OP_JoystickSetDef)
M_SetupJoystickMenu(0);
if (JoyInfo.dev != newjoy && JoyInfo2.dev != newjoy && JoyInfo3.dev != newjoy && JoyInfo4.dev != newjoy)
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (JoyInfo[i].dev == newjoy)
break;
}
if (i == MAXSPLITSCREENPLAYERS)
SDL_JoystickClose(newjoy);
}
break;
@ -1119,28 +1096,13 @@ void I_GetEvent(void)
////////////////////////////////////////////////////////////
case SDL_JOYDEVICEREMOVED:
if (JoyInfo.dev && !SDL_JoystickGetAttached(JoyInfo.dev))
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
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();
if (JoyInfo[i].dev && !SDL_JoystickGetAttached(JoyInfo[i].dev))
{
CONS_Debug(DBG_GAMELOGIC, "Joystick%d removed, device index: %d\n", i+1, JoyInfo[i].oldjoy);
I_ShutdownJoystick(i);
}
}
////////////////////////////////////////////////////////////
@ -1149,124 +1111,32 @@ void I_GetEvent(void)
// * 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;
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
I_UpdateJoystickDeviceIndex(i);
}
////////////////////////////////////////////////////////////
// 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);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
{
if (!strcmp(cv_usejoystick[i].string, "0"))
{
cv_usejoystick[i].value = 0;
}
else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
&& cv_usejoystick[i].value) // update the cvar ONLY if a device exists
{
CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].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);
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].oldjoy);
// update the menu
if (currentMenu == &OP_JoystickSetDef)
@ -1324,16 +1194,15 @@ void I_StartupMouse(void)
void I_OsPolling(void)
{
SDL_Keymod mod;
UINT8 i;
if (consolevent)
I_GetConsoleEvents();
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
{
SDL_JoystickUpdate();
I_GetJoystickEvents();
I_GetJoystick2Events();
I_GetJoystick3Events();
I_GetJoystick4Events();
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
I_GetJoystickEvents(i);
}
I_GetMouseEvents();

View file

@ -156,26 +156,11 @@ boolean OglSdlSurface(INT32 w, INT32 h)
{
INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
static boolean first_init = false;
const char *gllogdir = NULL;
oglflags = 0;
if (!first_init)
{
if (!gllogstream)
{
gllogdir = D_Home();
#ifdef DEBUG_TO_FILE
#ifdef DEFAULTDIR
if (gllogdir)
gllogstream = fopen(va("%s/"DEFAULTDIR"/ogllog.txt",gllogdir), "wt");
else
#endif
gllogstream = fopen("./ogllog.txt", "wt");
#endif
}
gl_version = pglGetString(GL_VERSION);
gl_renderer = pglGetString(GL_RENDERER);
gl_extensions = pglGetString(GL_EXTENSIONS);

View file

@ -23,6 +23,7 @@ extern SDL_bool consolevent;
extern SDL_bool framebuffer;
#include "../m_fixed.h"
#include "../doomdef.h"
// SDL2 stub macro
#ifdef _MSC_VER
@ -57,40 +58,26 @@ typedef struct SDLJoyInfo_s
} SDLJoyInfo_t;
/** \brief SDL info about joystick 1
/** \brief SDL info about joysticks
*/
extern SDLJoyInfo_t JoyInfo;
extern SDLJoyInfo_t JoyInfo[MAXSPLITSCREENPLAYERS];
/** \brief joystick axis deadzone
*/
#define SDL_JDEADZONE 153
#undef SDL_JDEADZONE
/** \brief SDL inof about joystick 2
*/
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);
// 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);
void I_ShutdownJoystick(UINT8 index);
// 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_UpdateJoystickDeviceIndex(UINT8 player);
void I_UpdateJoystickDeviceIndices(UINT8 excludePlayer);
void I_GetConsoleEvents(void);