Fix from JonoF for using a joystick in combination with SDLayer.

git-svn-id: https://svn.eduke32.com/eduke32@289 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2006-09-02 02:34:29 +00:00
parent c0f93c2aad
commit 11e8db76a8
2 changed files with 503 additions and 502 deletions

View file

@ -353,6 +353,7 @@ int initinput(void)
joydev = SDL_JoystickOpen(0); joydev = SDL_JoystickOpen(0);
if (joydev) { if (joydev) {
SDL_JoystickEventState(SDL_ENABLE); SDL_JoystickEventState(SDL_ENABLE);
inputdevices |= 4;
joynumaxes = SDL_JoystickNumAxes(joydev); joynumaxes = SDL_JoystickNumAxes(joydev);
joynumbuttons = min(32,SDL_JoystickNumButtons(joydev)); joynumbuttons = min(32,SDL_JoystickNumButtons(joydev));

View file

@ -35,14 +35,14 @@ static int32 CONTROL_NumJoyButtons = 0;
static int32 CONTROL_NumJoyAxes = 0; static int32 CONTROL_NumJoyAxes = 0;
static controlflags CONTROL_Flags[CONTROL_NUM_FLAGS]; static controlflags CONTROL_Flags[CONTROL_NUM_FLAGS];
static controlbuttontype CONTROL_MouseButtonMapping[MAXMOUSEBUTTONS], static controlbuttontype CONTROL_MouseButtonMapping[MAXMOUSEBUTTONS],
CONTROL_JoyButtonMapping[MAXJOYBUTTONS]; CONTROL_JoyButtonMapping[MAXJOYBUTTONS];
static controlkeymaptype CONTROL_KeyMapping[CONTROL_NUM_FLAGS]; static controlkeymaptype CONTROL_KeyMapping[CONTROL_NUM_FLAGS];
static controlaxismaptype CONTROL_MouseAxesMap[MAXMOUSEAXES], // maps physical axes onto virtual ones static controlaxismaptype CONTROL_MouseAxesMap[MAXMOUSEAXES], // maps physical axes onto virtual ones
CONTROL_JoyAxesMap[MAXJOYAXES]; CONTROL_JoyAxesMap[MAXJOYAXES];
static controlaxistype CONTROL_MouseAxes[MAXMOUSEAXES], // physical axes static controlaxistype CONTROL_MouseAxes[MAXMOUSEAXES], // physical axes
CONTROL_JoyAxes[MAXJOYAXES]; CONTROL_JoyAxes[MAXJOYAXES];
static controlaxistype CONTROL_LastMouseAxes[MAXMOUSEAXES], static controlaxistype CONTROL_LastMouseAxes[MAXMOUSEAXES],
CONTROL_LastJoyAxes[MAXJOYAXES]; CONTROL_LastJoyAxes[MAXJOYAXES];
static int32 CONTROL_MouseAxesScale[MAXMOUSEAXES], CONTROL_JoyAxesScale[MAXJOYAXES]; static int32 CONTROL_MouseAxesScale[MAXMOUSEAXES], CONTROL_JoyAxesScale[MAXJOYAXES];
static int32 CONTROL_MouseButtonState[MAXMOUSEBUTTONS], CONTROL_JoyButtonState[MAXJOYBUTTONS]; static int32 CONTROL_MouseButtonState[MAXMOUSEBUTTONS], CONTROL_JoyButtonState[MAXJOYBUTTONS];
static int32 CONTROL_MouseButtonClickedTime[MAXMOUSEBUTTONS], CONTROL_JoyButtonClickedTime[MAXJOYBUTTONS]; static int32 CONTROL_MouseButtonClickedTime[MAXMOUSEBUTTONS], CONTROL_JoyButtonClickedTime[MAXJOYBUTTONS];
@ -114,19 +114,19 @@ void CONTROL_SetJoyScale( void )
} }
void CONTROL_CenterJoystick void CONTROL_CenterJoystick
( (
void ( *CenterCenter )( void ), void ( *CenterCenter )( void ),
void ( *UpperLeft )( void ), void ( *UpperLeft )( void ),
void ( *LowerRight )( void ), void ( *LowerRight )( void ),
void ( *CenterThrottle )( void ), void ( *CenterThrottle )( void ),
void ( *CenterRudder )( void ) void ( *CenterRudder )( void )
) )
{ {
} }
boolean CONTROL_StartJoy(int32 joy) boolean CONTROL_StartJoy(int32 joy)
{ {
return (inputdevices & 3) == 3; return (inputdevices & 4) == 4;
} }
void CONTROL_ShutJoy(int32 joy) void CONTROL_ShutJoy(int32 joy)
@ -867,7 +867,7 @@ boolean CONTROL_Startup(controltype which, int32 ( *TimeFunction )( void ), int3
// case controltype_keyboardandjoystick: // case controltype_keyboardandjoystick:
CONTROL_NumJoyAxes = min(MAXJOYAXES,joynumaxes); CONTROL_NumJoyAxes = min(MAXJOYAXES,joynumaxes);
CONTROL_NumJoyButtons = min(MAXJOYBUTTONS,joynumbuttons + 4*(joynumhats>0)); CONTROL_NumJoyButtons = min(MAXJOYBUTTONS,joynumbuttons + 4*(joynumhats>0));
CONTROL_JoyPresent = ((inputdevices & 4) == 4); CONTROL_JoyPresent = CONTROL_StartJoy(0);;
CONTROL_JoystickEnabled = CONTROL_JoyPresent; CONTROL_JoystickEnabled = CONTROL_JoyPresent;
// break; // break;
//} //}