keep track of joystick index in struct
This commit is contained in:
1 parent
b14d1f1e0b
commit
cd57ebd763
2 files changed
+6
-4
No files matched your search
+4
-3
@@ -1113,7 +1113,7 @@ void I_UpdateJoystickDeviceIndex(UINT8 player)
|
||||
///////////////////////////////////////////////
|
||||
if (JoyInfo[player].dev)
|
||||
{
|
||||
cv_usejoystick[player].value = I_GetJoystickDeviceIndex(JoyInfo[player].dev) + 1;
|
||||
cv_usejoystick[player].value = JoyInfo[player].id + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1303,6 +1303,7 @@ static int joy_open(int playerIndex, int joyIndex)
|
||||
}
|
||||
|
||||
JoyInfo[playerIndex].dev = newdev;
|
||||
JoyInfo[playerIndex].id = I_GetJoystickDeviceIndex(JoyInfo[playerIndex].dev);
|
||||
|
||||
if (JoyInfo[playerIndex].dev == NULL)
|
||||
{
|
||||
@@ -1385,13 +1386,13 @@ void I_InitJoystick(UINT8 index)
|
||||
|
||||
if (newcontroller && i < MAXSPLITSCREENPLAYERS) // don't override an active device
|
||||
{
|
||||
cv_usejoystick[index].value = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
|
||||
cv_usejoystick[index].value = JoyInfo[index].id + 1;
|
||||
}
|
||||
else if (newcontroller && joy_open(index, cv_usejoystick[index].value) != -1)
|
||||
{
|
||||
// SDL's device indexes are unstable, so cv_usejoystick may not match
|
||||
// the actual device index. So let's cheat a bit and find the device's current index.
|
||||
JoyInfo[index].oldjoy = I_GetJoystickDeviceIndex(JoyInfo[index].dev) + 1;
|
||||
JoyInfo[index].oldjoy = JoyInfo[index].id + 1;
|
||||
joystick_started[index] = 1;
|
||||
}
|
||||
else
|
||||
|
||||
+2
-1
@@ -42,6 +42,8 @@ typedef struct SDLJoyInfo_s
|
||||
{
|
||||
/// Controller handle
|
||||
SDL_GameController *dev;
|
||||
/// Controller index
|
||||
INT32 id;
|
||||
/// number of old joystick
|
||||
int oldjoy;
|
||||
/// number of axies
|
||||
@@ -54,7 +56,6 @@ typedef struct SDLJoyInfo_s
|
||||
int hats;
|
||||
/// number of balls
|
||||
int balls;
|
||||
|
||||
} SDLJoyInfo_t;
|
||||
|
||||
/** \brief SDL info about controller 1
|
||||
|
||||
Reference in new issue
Block a user