mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
SDL files
This commit is contained in:
parent
9efdc98de6
commit
f12501dfb6
5 changed files with 297 additions and 1850 deletions
|
|
@ -184,9 +184,13 @@ void I_JoyScale4(void);
|
||||||
|
|
||||||
// Called by D_SRB2Main.
|
// Called by D_SRB2Main.
|
||||||
|
|
||||||
|
/** \brief to startup a joystick
|
||||||
|
*/
|
||||||
|
void I_InitJoystick(UINT8 index);
|
||||||
|
|
||||||
/** \brief to startup the first joystick
|
/** \brief to startup the first joystick
|
||||||
*/
|
*/
|
||||||
void I_InitJoystick(void);
|
void I_InitJoystick1(void);
|
||||||
|
|
||||||
/** \brief to startup the second joystick
|
/** \brief to startup the second joystick
|
||||||
*/
|
*/
|
||||||
|
|
@ -318,19 +322,7 @@ const char *I_LocateWad(void);
|
||||||
|
|
||||||
/** \brief First Joystick's events
|
/** \brief First Joystick's events
|
||||||
*/
|
*/
|
||||||
void I_GetJoystickEvents(void);
|
void I_GetJoystickEvents(UINT8 index);
|
||||||
|
|
||||||
/** \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);
|
|
||||||
|
|
||||||
/** \brief Mouses events
|
/** \brief Mouses events
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
1766
src/sdl/i_system.c
1766
src/sdl/i_system.c
File diff suppressed because it is too large
Load diff
|
|
@ -528,7 +528,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||||
INT32 raxis = axis/32;
|
INT32 raxis = axis/32;
|
||||||
if (which == ev_joystick)
|
if (which == ev_joystick)
|
||||||
{
|
{
|
||||||
if (Joystick.bGamepadStyle)
|
if (Joystick[0].bGamepadStyle)
|
||||||
{
|
{
|
||||||
// gamepad control type, on or off, live or die
|
// gamepad control type, on or off, live or die
|
||||||
if (raxis < -(JOYAXISRANGE/2))
|
if (raxis < -(JOYAXISRANGE/2))
|
||||||
|
|
@ -540,7 +540,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||||
}
|
}
|
||||||
else
|
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
|
#ifdef SDL_JDEADZONE
|
||||||
if (-SDL_JDEADZONE <= raxis && raxis <= 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)
|
else if (which == ev_joystick2)
|
||||||
{
|
{
|
||||||
if (Joystick2.bGamepadStyle)
|
if (Joystick[1].bGamepadStyle)
|
||||||
{
|
{
|
||||||
// gamepad control type, on or off, live or die
|
// gamepad control type, on or off, live or die
|
||||||
if (raxis < -(JOYAXISRANGE/2))
|
if (raxis < -(JOYAXISRANGE/2))
|
||||||
|
|
@ -561,7 +561,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||||
}
|
}
|
||||||
else
|
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
|
#ifdef SDL_JDEADZONE
|
||||||
if (-SDL_JDEADZONE <= raxis && raxis <= 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)
|
else if (which == ev_joystick3)
|
||||||
{
|
{
|
||||||
if (Joystick3.bGamepadStyle)
|
if (Joystick[2].bGamepadStyle)
|
||||||
{
|
{
|
||||||
// gamepad control type, on or off, live or die
|
// gamepad control type, on or off, live or die
|
||||||
if (raxis < -(JOYAXISRANGE/2))
|
if (raxis < -(JOYAXISRANGE/2))
|
||||||
|
|
@ -582,7 +582,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||||
}
|
}
|
||||||
else
|
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
|
#ifdef SDL_JDEADZONE
|
||||||
if (-SDL_JDEADZONE <= raxis && raxis <= 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)
|
else if (which == ev_joystick4)
|
||||||
{
|
{
|
||||||
if (Joystick4.bGamepadStyle)
|
if (Joystick[3].bGamepadStyle)
|
||||||
{
|
{
|
||||||
// gamepad control type, on or off, live or die
|
// gamepad control type, on or off, live or die
|
||||||
if (raxis < -(JOYAXISRANGE/2))
|
if (raxis < -(JOYAXISRANGE/2))
|
||||||
|
|
@ -603,7 +603,7 @@ static INT32 SDLJoyAxis(const Sint16 axis, evtype_t which)
|
||||||
}
|
}
|
||||||
else
|
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
|
#ifdef SDL_JDEADZONE
|
||||||
if (-SDL_JDEADZONE <= raxis && raxis <= 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)
|
static void Impl_HandleJoystickAxisEvent(SDL_JoyAxisEvent evt)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event;
|
||||||
SDL_JoystickID joyid[4];
|
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
// Determine the Joystick IDs for each current open joystick
|
// Determine the Joystick IDs for each current open joystick
|
||||||
joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev);
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev);
|
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
|
||||||
joyid[2] = SDL_JoystickInstanceID(JoyInfo3.dev);
|
|
||||||
joyid[3] = SDL_JoystickInstanceID(JoyInfo4.dev);
|
|
||||||
|
|
||||||
evt.axis++;
|
evt.axis++;
|
||||||
event.data1 = event.data2 = event.data3 = INT32_MAX;
|
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)
|
static void Impl_HandleJoystickHatEvent(SDL_JoyHatEvent evt)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event;
|
||||||
SDL_JoystickID joyid[2];
|
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
// Determine the Joystick IDs for each current open joystick
|
// Determine the Joystick IDs for each current open joystick
|
||||||
joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev);
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev);
|
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
|
||||||
|
|
||||||
if (evt.hat >= JOYHATS)
|
if (evt.hat >= JOYHATS)
|
||||||
return; // ignore hats with too high an index
|
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);
|
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;
|
else return;
|
||||||
|
|
||||||
// NOTE: UNFINISHED
|
// NOTE: UNFINISHED
|
||||||
|
|
@ -899,13 +907,12 @@ static void Impl_HandleJoystickHatEvent(SDL_JoyHatEvent evt)
|
||||||
static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
|
static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
|
||||||
{
|
{
|
||||||
event_t event;
|
event_t event;
|
||||||
SDL_JoystickID joyid[4];
|
SDL_JoystickID joyid[MAXSPLITSCREENPLAYERS];
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
// Determine the Joystick IDs for each current open joystick
|
// Determine the Joystick IDs for each current open joystick
|
||||||
joyid[0] = SDL_JoystickInstanceID(JoyInfo.dev);
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
joyid[1] = SDL_JoystickInstanceID(JoyInfo2.dev);
|
joyid[i] = SDL_JoystickInstanceID(JoyInfo[i].dev);
|
||||||
joyid[2] = SDL_JoystickInstanceID(JoyInfo3.dev);
|
|
||||||
joyid[3] = SDL_JoystickInstanceID(JoyInfo4.dev);
|
|
||||||
|
|
||||||
if (evt.which == joyid[0])
|
if (evt.which == joyid[0])
|
||||||
{
|
{
|
||||||
|
|
@ -948,10 +955,13 @@ static void Impl_HandleJoystickButtonEvent(SDL_JoyButtonEvent evt, Uint32 type)
|
||||||
void I_GetEvent(void)
|
void I_GetEvent(void)
|
||||||
{
|
{
|
||||||
SDL_Event evt;
|
SDL_Event evt;
|
||||||
|
|
||||||
// We only want the first motion event,
|
// We only want the first motion event,
|
||||||
// otherwise we'll end up catching the warp back to center.
|
// otherwise we'll end up catching the warp back to center.
|
||||||
//int mouseMotionOnce = 0;
|
//int mouseMotionOnce = 0;
|
||||||
|
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
if (!graphics_started)
|
if (!graphics_started)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
@ -1016,77 +1026,42 @@ void I_GetEvent(void)
|
||||||
// * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value!
|
// * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value!
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
//////////////////////////////
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
// 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;
|
if (newjoy && (!JoyInfo[i].dev || !SDL_JoystickGetAttached(JoyInfo[i].dev)))
|
||||||
I_UpdateJoystickDeviceIndices(1);
|
{
|
||||||
}
|
UINT8 j;
|
||||||
|
|
||||||
//////////////////////////////
|
for (j = 0; j < MAXSPLITSCREENPLAYERS; j++)
|
||||||
// PLAYER 2
|
{
|
||||||
//////////////////////////////
|
if (i == j)
|
||||||
|
continue;
|
||||||
|
|
||||||
else if (newjoy && (!JoyInfo2.dev || !SDL_JoystickGetAttached(JoyInfo2.dev))
|
if (JoyInfo[j].dev == newjoy)
|
||||||
&& JoyInfo.dev != newjoy && JoyInfo3.dev != newjoy && JoyInfo4.dev != newjoy) // don't override a currently active device
|
break;
|
||||||
{
|
}
|
||||||
cv_usejoystick2.value = evt.jdevice.which + 1;
|
|
||||||
I_UpdateJoystickDeviceIndices(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////
|
if (j == MAXSPLITSCREENPLAYERS)
|
||||||
// PLAYER 3
|
{
|
||||||
//////////////////////////////
|
// ensures we aren't overriding a currently active device
|
||||||
|
cv_usejoystick[i].value = evt.jdevice.which + 1;
|
||||||
else if (newjoy && (!JoyInfo3.dev || !SDL_JoystickGetAttached(JoyInfo3.dev))
|
I_UpdateJoystickDeviceIndices(0);
|
||||||
&& 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?
|
// Was cv_usejoystick disabled in settings?
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if (!strcmp(cv_usejoystick.string, "0") || !cv_usejoystick.value)
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
cv_usejoystick.value = 0;
|
{
|
||||||
else if (atoi(cv_usejoystick.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
if (!strcmp(cv_usejoystick[i].string, "0") || !cv_usejoystick[i].value)
|
||||||
&& cv_usejoystick.value) // update the cvar ONLY if a device exists
|
cv_usejoystick[i].value = 0;
|
||||||
CV_SetValue(&cv_usejoystick, cv_usejoystick.value);
|
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
|
||||||
if (!strcmp(cv_usejoystick2.string, "0") || !cv_usejoystick2.value)
|
CV_SetValue(&cv_usejoystick[i], cv_usejoystick[i].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
|
// Update all joysticks' init states
|
||||||
|
|
@ -1095,23 +1070,25 @@ void I_GetEvent(void)
|
||||||
// if the device is already active, this should do nothing, effectively.
|
// if the device is already active, this should do nothing, effectively.
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
I_InitJoystick();
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
I_InitJoystick2();
|
I_InitJoystick(i);
|
||||||
I_InitJoystick3();
|
|
||||||
I_InitJoystick4();
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
CONS_Debug(DBG_GAMELOGIC, "Joystick1 device index: %d\n", JoyInfo.oldjoy);
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
CONS_Debug(DBG_GAMELOGIC, "Joystick2 device index: %d\n", JoyInfo2.oldjoy);
|
CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].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
|
// update the menu
|
||||||
if (currentMenu == &OP_JoystickSetDef)
|
if (currentMenu == &OP_JoystickSetDef)
|
||||||
M_SetupJoystickMenu(0);
|
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);
|
SDL_JoystickClose(newjoy);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1119,28 +1096,13 @@ void I_GetEvent(void)
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
case SDL_JOYDEVICEREMOVED:
|
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);
|
if (JoyInfo[i].dev && !SDL_JoystickGetAttached(JoyInfo[i].dev))
|
||||||
I_ShutdownJoystick();
|
{
|
||||||
}
|
CONS_Debug(DBG_GAMELOGIC, "Joystick%d removed, device index: %d\n", i+1, JoyInfo[i].oldjoy);
|
||||||
|
I_ShutdownJoystick(i);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
@ -1149,124 +1111,32 @@ void I_GetEvent(void)
|
||||||
// * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value!
|
// * BUT: If that default index is being occupied, use ANOTHER cv_usejoystick's default value!
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if (JoyInfo.dev)
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
cv_usejoystick.value = JoyInfo.oldjoy = I_GetJoystickDeviceIndex(JoyInfo.dev) + 1;
|
{
|
||||||
else if (atoi(cv_usejoystick.string) != JoyInfo2.oldjoy
|
I_UpdateJoystickDeviceIndex(i);
|
||||||
&& 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?
|
// Was cv_usejoystick disabled in settings?
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
if (!strcmp(cv_usejoystick.string, "0"))
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
cv_usejoystick.value = 0;
|
{
|
||||||
else if (atoi(cv_usejoystick.string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
if (!strcmp(cv_usejoystick[i].string, "0"))
|
||||||
&& cv_usejoystick.value) // update the cvar ONLY if a device exists
|
{
|
||||||
CV_SetValue(&cv_usejoystick, cv_usejoystick.value);
|
cv_usejoystick[i].value = 0;
|
||||||
|
}
|
||||||
if (!strcmp(cv_usejoystick2.string, "0"))
|
else if (atoi(cv_usejoystick[i].string) <= I_NumJoys() // don't mess if we intentionally set higher than NumJoys
|
||||||
cv_usejoystick2.value = 0;
|
&& cv_usejoystick[i].value) // update the cvar ONLY if a device exists
|
||||||
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_usejoystick[i], cv_usejoystick[i].value);
|
||||||
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);
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
CONS_Debug(DBG_GAMELOGIC, "Joystick2 device index: %d\n", JoyInfo2.oldjoy);
|
CONS_Debug(DBG_GAMELOGIC, "Joystick%d device index: %d\n", i+1, JoyInfo[i].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
|
// update the menu
|
||||||
if (currentMenu == &OP_JoystickSetDef)
|
if (currentMenu == &OP_JoystickSetDef)
|
||||||
|
|
@ -1324,16 +1194,15 @@ void I_StartupMouse(void)
|
||||||
void I_OsPolling(void)
|
void I_OsPolling(void)
|
||||||
{
|
{
|
||||||
SDL_Keymod mod;
|
SDL_Keymod mod;
|
||||||
|
UINT8 i;
|
||||||
|
|
||||||
if (consolevent)
|
if (consolevent)
|
||||||
I_GetConsoleEvents();
|
I_GetConsoleEvents();
|
||||||
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
if (SDL_WasInit(SDL_INIT_JOYSTICK) == SDL_INIT_JOYSTICK)
|
||||||
{
|
{
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
I_GetJoystickEvents();
|
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||||
I_GetJoystick2Events();
|
I_GetJoystickEvents(i);
|
||||||
I_GetJoystick3Events();
|
|
||||||
I_GetJoystick4Events();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
I_GetMouseEvents();
|
I_GetMouseEvents();
|
||||||
|
|
|
||||||
|
|
@ -156,26 +156,11 @@ boolean OglSdlSurface(INT32 w, INT32 h)
|
||||||
{
|
{
|
||||||
INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
|
INT32 cbpp = cv_scr_depth.value < 16 ? 16 : cv_scr_depth.value;
|
||||||
static boolean first_init = false;
|
static boolean first_init = false;
|
||||||
const char *gllogdir = NULL;
|
|
||||||
|
|
||||||
oglflags = 0;
|
oglflags = 0;
|
||||||
|
|
||||||
if (!first_init)
|
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_version = pglGetString(GL_VERSION);
|
||||||
gl_renderer = pglGetString(GL_RENDERER);
|
gl_renderer = pglGetString(GL_RENDERER);
|
||||||
gl_extensions = pglGetString(GL_EXTENSIONS);
|
gl_extensions = pglGetString(GL_EXTENSIONS);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ extern SDL_bool consolevent;
|
||||||
extern SDL_bool framebuffer;
|
extern SDL_bool framebuffer;
|
||||||
|
|
||||||
#include "../m_fixed.h"
|
#include "../m_fixed.h"
|
||||||
|
#include "../doomdef.h"
|
||||||
|
|
||||||
// SDL2 stub macro
|
// SDL2 stub macro
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
|
@ -57,40 +58,26 @@ typedef struct SDLJoyInfo_s
|
||||||
|
|
||||||
} SDLJoyInfo_t;
|
} 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
|
/** \brief joystick axis deadzone
|
||||||
*/
|
*/
|
||||||
#define SDL_JDEADZONE 153
|
#define SDL_JDEADZONE 153
|
||||||
#undef SDL_JDEADZONE
|
#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);
|
void I_GetConsoleEvents(void);
|
||||||
|
|
||||||
// So we can call this from i_video event loop
|
// So we can call this from i_video event loop
|
||||||
void I_ShutdownJoystick(void);
|
void I_ShutdownJoystick(UINT8 index);
|
||||||
void I_ShutdownJoystick2(void);
|
|
||||||
void I_ShutdownJoystick3(void);
|
|
||||||
void I_ShutdownJoystick4(void);
|
|
||||||
|
|
||||||
// Cheat to get the device index for a joystick handle
|
// Cheat to get the device index for a joystick handle
|
||||||
INT32 I_GetJoystickDeviceIndex(SDL_Joystick *dev);
|
INT32 I_GetJoystickDeviceIndex(SDL_Joystick *dev);
|
||||||
|
|
||||||
// Quick thing to make SDL_JOYDEVICEADDED events less of an abomination
|
// 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);
|
void I_GetConsoleEvents(void);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue