mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-23 04:11:53 +00:00
Controllers now communicate analog trigger keys in SDL2 builds.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5985 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
7800434ecb
commit
1c038872f3
1 changed files with 11 additions and 4 deletions
|
@ -171,7 +171,7 @@ static struct sdljoy_s *J_DevId(SDL_JoystickID jid)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static void J_ControllerAxis(SDL_JoystickID jid, int axis, int value)
|
static void J_ControllerAxis(SDL_JoystickID jid, int axis, int value)
|
||||||
{ //FIXME: sdlaxis 4 and 5 should trigger K_GP_LEFT_TRIGGER and K_GP_RIGHT_TRIGGER
|
{
|
||||||
int axismap[] = {
|
int axismap[] = {
|
||||||
// SDL_CONTROLLER_AXIS_LEFTX, SDL_CONTROLLER_AXIS_LEFTY, SDL_CONTROLLER_AXIS_RIGHTX,
|
// SDL_CONTROLLER_AXIS_LEFTX, SDL_CONTROLLER_AXIS_LEFTY, SDL_CONTROLLER_AXIS_RIGHTX,
|
||||||
GPAXIS_LT_RIGHT, GPAXIS_LT_DOWN, GPAXIS_RT_RIGHT,
|
GPAXIS_LT_RIGHT, GPAXIS_LT_DOWN, GPAXIS_RT_RIGHT,
|
||||||
|
@ -179,9 +179,16 @@ static void J_ControllerAxis(SDL_JoystickID jid, int axis, int value)
|
||||||
GPAXIS_RT_DOWN, GPAXIS_LT_TRIGGER, GPAXIS_RT_TRIGGER};
|
GPAXIS_RT_DOWN, GPAXIS_LT_TRIGGER, GPAXIS_RT_TRIGGER};
|
||||||
|
|
||||||
struct sdljoy_s *joy = J_DevId(jid);
|
struct sdljoy_s *joy = J_DevId(jid);
|
||||||
if (joy && axis < sizeof(axismap)/sizeof(axismap[0]) && joy->qdevid != DEVID_UNSET)
|
if (joy && axis < sizeof(axismap)/sizeof(axismap[0]) && joy->qdevid != DEVID_UNSET) {
|
||||||
|
/* hack to allow for RTRIGGER and LTRIGGER */
|
||||||
|
if (axis == 4)
|
||||||
|
IN_KeyEvent(joy->qdevid, (value > 128) ? 1 : 0, K_GP_LEFT_TRIGGER, 0);
|
||||||
|
else if (axis == 5)
|
||||||
|
IN_KeyEvent(joy->qdevid, (value > 128) ? 1 : 0, K_GP_RIGHT_TRIGGER, 0);
|
||||||
|
else
|
||||||
IN_JoystickAxisEvent(joy->qdevid, axismap[axis], value / 32767.0);
|
IN_JoystickAxisEvent(joy->qdevid, axismap[axis], value / 32767.0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
static void J_JoystickAxis(SDL_JoystickID jid, int axis, int value)
|
static void J_JoystickAxis(SDL_JoystickID jid, int axis, int value)
|
||||||
{
|
{
|
||||||
int axismap[] = {0,1,3,4,2,5};
|
int axismap[] = {0,1,3,4,2,5};
|
||||||
|
@ -977,7 +984,7 @@ void Sys_SendKeyEvents(void)
|
||||||
// break;
|
// break;
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_JOYBUTTONDOWN:
|
||||||
case SDL_JOYBUTTONUP:
|
case SDL_JOYBUTTONUP:
|
||||||
J_JoystickButton(event.jbutton.which, event.jbutton.button, event.type==SDL_CONTROLLERBUTTONDOWN);
|
J_JoystickButton(event.jbutton.which, event.jbutton.button, (event.type==SDL_CONTROLLERBUTTONDOWN) ? 1 : 0);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYDEVICEADDED:
|
case SDL_JOYDEVICEADDED:
|
||||||
J_JoystickAdded(event.jdevice.which);
|
J_JoystickAdded(event.jdevice.which);
|
||||||
|
|
Loading…
Reference in a new issue