mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Implement contoller analog 0 in menus very hackishly
git-svn-id: https://svn.eduke32.com/eduke32@7970 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
e19511cad7
commit
791f8376b6
4 changed files with 62 additions and 2 deletions
|
@ -169,6 +169,7 @@ int32_t I_MenuUp(void)
|
|||
|| BUTTON(gamefunc_Move_Forward)
|
||||
|| (JOYSTICK_GetHat(0)&HAT_UP)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_UP))
|
||||
|| CONTROL_GetGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTY)
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -180,6 +181,7 @@ void I_MenuUpClear(void)
|
|||
CONTROL_ClearButton(gamefunc_Move_Forward);
|
||||
JOYSTICK_ClearHat(0);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_UP);
|
||||
CONTROL_ClearGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTY);
|
||||
}
|
||||
|
||||
|
||||
|
@ -192,6 +194,7 @@ int32_t I_MenuDown(void)
|
|||
|| BUTTON(gamefunc_Move_Backward)
|
||||
|| (JOYSTICK_GetHat(0)&HAT_DOWN)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN))
|
||||
|| CONTROL_GetGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTY)
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -204,6 +207,7 @@ void I_MenuDownClear(void)
|
|||
CONTROL_ClearButton(gamefunc_Move_Backward);
|
||||
JOYSTICK_ClearHat(0);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN);
|
||||
CONTROL_ClearGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTY);
|
||||
}
|
||||
|
||||
|
||||
|
@ -217,6 +221,7 @@ int32_t I_MenuLeft(void)
|
|||
|| BUTTON(gamefunc_Strafe_Left)
|
||||
|| (JOYSTICK_GetHat(0)&HAT_LEFT)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT))
|
||||
|| CONTROL_GetGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTX)
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -229,6 +234,7 @@ void I_MenuLeftClear(void)
|
|||
CONTROL_ClearButton(gamefunc_Strafe_Left);
|
||||
JOYSTICK_ClearHat(0);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT);
|
||||
CONTROL_ClearGameControllerDigitalAxisNeg(GAMECONTROLLER_AXIS_LEFTX);
|
||||
}
|
||||
|
||||
|
||||
|
@ -243,6 +249,7 @@ int32_t I_MenuRight(void)
|
|||
|| (MOUSE_GetButtons()&MIDDLE_MOUSE)
|
||||
|| (JOYSTICK_GetHat(0)&HAT_RIGHT)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT))
|
||||
|| CONTROL_GetGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTX)
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -256,6 +263,7 @@ void I_MenuRightClear(void)
|
|||
MOUSE_ClearButton(MIDDLE_MOUSE);
|
||||
JOYSTICK_ClearHat(0);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT);
|
||||
CONTROL_ClearGameControllerDigitalAxisPos(GAMECONTROLLER_AXIS_LEFTX);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -172,6 +172,7 @@ typedef struct
|
|||
{
|
||||
int32_t analog;
|
||||
int32_t digital;
|
||||
int16_t digitalClearedN, digitalClearedP;
|
||||
} controlaxistype;
|
||||
|
||||
|
||||
|
|
|
@ -198,6 +198,11 @@ void CONTROL_MapAnalogAxis(int whichaxis, int whichanalog, controldevice device)
|
|||
void CONTROL_MapDigitalAxis(int32_t whichaxis, int32_t whichfunction, int32_t direction, controldevice device);
|
||||
void CONTROL_SetAnalogAxisScale(int32_t whichaxis, int32_t axisscale, controldevice device);
|
||||
|
||||
int32_t CONTROL_GetGameControllerDigitalAxisPos(int32_t axis);
|
||||
int32_t CONTROL_GetGameControllerDigitalAxisNeg(int32_t axis);
|
||||
void CONTROL_ClearGameControllerDigitalAxisPos(int32_t axis);
|
||||
void CONTROL_ClearGameControllerDigitalAxisNeg(int32_t axis);
|
||||
|
||||
//void CONTROL_PrintKeyMap(void);
|
||||
//void CONTROL_PrintControlFlag(int32_t which);
|
||||
//void CONTROL_PrintAxes( void );
|
||||
|
|
|
@ -538,15 +538,31 @@ static void CONTROL_DigitizeAxis(int axis, controldevice device)
|
|||
default: return;
|
||||
}
|
||||
|
||||
set[axis].digitalClearedN = lastset[axis].digitalClearedN;
|
||||
set[axis].digitalClearedP = lastset[axis].digitalClearedP;
|
||||
|
||||
if (set[axis].analog > 0)
|
||||
{
|
||||
set[axis].digitalClearedN = 0;
|
||||
|
||||
if (set[axis].analog > THRESHOLD || (set[axis].analog > MINTHRESHOLD && lastset[axis].digital == 1))
|
||||
set[axis].digital = 1;
|
||||
else
|
||||
set[axis].digitalClearedP = 0;
|
||||
}
|
||||
else if (set[axis].analog < 0)
|
||||
{
|
||||
set[axis].digitalClearedP = 0;
|
||||
|
||||
if (set[axis].analog < -THRESHOLD || (set[axis].analog < -MINTHRESHOLD && lastset[axis].digital == -1))
|
||||
set[axis].digital = -1;
|
||||
else
|
||||
set[axis].digitalClearedN = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (set[axis].analog < -THRESHOLD || (set[axis].analog < -MINTHRESHOLD && lastset[axis].digital == -1))
|
||||
set[axis].digital = -1;
|
||||
set[axis].digitalClearedN = 0;
|
||||
set[axis].digitalClearedP = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -744,6 +760,36 @@ void CONTROL_ClearAllButtons(void)
|
|||
c.cleared = TRUE;
|
||||
}
|
||||
|
||||
int32_t CONTROL_GetGameControllerDigitalAxisPos(int32_t axis)
|
||||
{
|
||||
if (!joystick.isGameController)
|
||||
return 0;
|
||||
|
||||
return CONTROL_JoyAxes[axis].digital > 0 && !CONTROL_JoyAxes[axis].digitalClearedP;
|
||||
}
|
||||
int32_t CONTROL_GetGameControllerDigitalAxisNeg(int32_t axis)
|
||||
{
|
||||
if (!joystick.isGameController)
|
||||
return 0;
|
||||
|
||||
return CONTROL_JoyAxes[axis].digital < 0 && !CONTROL_JoyAxes[axis].digitalClearedN;
|
||||
}
|
||||
|
||||
void CONTROL_ClearGameControllerDigitalAxisPos(int32_t axis)
|
||||
{
|
||||
if (!joystick.isGameController)
|
||||
return;
|
||||
|
||||
CONTROL_JoyAxes[axis].digitalClearedP = 1;
|
||||
}
|
||||
void CONTROL_ClearGameControllerDigitalAxisNeg(int32_t axis)
|
||||
{
|
||||
if (!joystick.isGameController)
|
||||
return;
|
||||
|
||||
CONTROL_JoyAxes[axis].digitalClearedN = 1;
|
||||
}
|
||||
|
||||
void CONTROL_ProcessBinds(void)
|
||||
{
|
||||
if (!CONTROL_BindsEnabled)
|
||||
|
|
Loading…
Reference in a new issue