mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 17:01:28 +00:00
Implement controller defaults
git-svn-id: https://svn.eduke32.com/eduke32@7968 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
5c96fcb334
commit
b4362aa6a9
11 changed files with 415 additions and 129 deletions
|
@ -111,7 +111,7 @@ static SDL_Surface *loadappicon(void);
|
|||
static mutex_t m_initprintf;
|
||||
|
||||
// Joystick dead and saturation zones
|
||||
uint16_t *joydead, *joysatur;
|
||||
uint16_t joydead[9], joysatur[9];
|
||||
|
||||
#ifdef _WIN32
|
||||
# if SDL_MAJOR_VERSION != 1
|
||||
|
@ -918,9 +918,6 @@ int32_t initinput(void)
|
|||
|
||||
joystick.pAxis = (int32_t *)Xcalloc(joystick.numAxes, sizeof(int32_t));
|
||||
|
||||
joydead = (uint16_t *)Xcalloc(joystick.numAxes, sizeof(uint16_t));
|
||||
joysatur = (uint16_t *)Xcalloc(joystick.numAxes, sizeof(uint16_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -948,9 +945,6 @@ int32_t initinput(void)
|
|||
|
||||
for (i = 0; i < joystick.numHats; i++) joystick.pHat[i] = -1; // centre
|
||||
|
||||
joydead = (uint16_t *)Xcalloc(joystick.numAxes, sizeof(uint16_t));
|
||||
joysatur = (uint16_t *)Xcalloc(joystick.numAxes, sizeof(uint16_t));
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,7 +279,7 @@ static const char * mousedigitaldefaults[MAXMOUSEDIGITAL] =
|
|||
{
|
||||
};
|
||||
|
||||
#if defined(GEKKO)
|
||||
#if defined GEKKO
|
||||
static const char * joystickdefaults[MAXJOYBUTTONSANDHATS] =
|
||||
{
|
||||
"Open", // A
|
||||
|
@ -331,25 +331,6 @@ static const char * joystickanalogdefaults[MAXJOYAXES] =
|
|||
};
|
||||
|
||||
|
||||
static const char * joystickdigitaldefaults[MAXJOYDIGITAL] =
|
||||
{
|
||||
};
|
||||
#else
|
||||
static const char * joystickdefaults[MAXJOYBUTTONSANDHATS] =
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
static const char * joystickclickeddefaults[MAXJOYBUTTONSANDHATS] =
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
static const char * joystickanalogdefaults[MAXJOYAXES] =
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
static const char * joystickdigitaldefaults[MAXJOYDIGITAL] =
|
||||
{
|
||||
};
|
||||
|
|
|
@ -96,6 +96,34 @@ static char const * CONFIG_AnalogNumToName(int32_t func)
|
|||
}
|
||||
|
||||
|
||||
static void CONFIG_SetJoystickButtonFunction(int i, int j, int function)
|
||||
{
|
||||
ud.config.JoystickFunctions[i][j] = function;
|
||||
CONTROL_MapButton(function, i, j, controldevice_joystick);
|
||||
}
|
||||
static void CONFIG_SetJoystickAnalogAxisScale(int i, int scale)
|
||||
{
|
||||
ud.config.JoystickAnalogueScale[i] = scale;
|
||||
CONTROL_SetAnalogAxisScale(i, scale, controldevice_joystick);
|
||||
}
|
||||
static void CONFIG_SetJoystickAnalogAxisDeadSaturate(int i, int dead, int saturate)
|
||||
{
|
||||
ud.config.JoystickAnalogueDead[i] = dead;
|
||||
ud.config.JoystickAnalogueSaturate[i] = saturate;
|
||||
joySetDeadZone(i, dead, saturate);
|
||||
}
|
||||
static void CONFIG_SetJoystickDigitalAxisFunction(int i, int j, int function)
|
||||
{
|
||||
ud.config.JoystickDigitalFunctions[i][j] = function;
|
||||
CONTROL_MapDigitalAxis(i, function, j, controldevice_joystick);
|
||||
}
|
||||
static void CONFIG_SetJoystickAnalogAxisFunction(int i, int function)
|
||||
{
|
||||
ud.config.JoystickAnalogueAxes[i] = function;
|
||||
CONTROL_MapAnalogAxis(i, function, controldevice_joystick);
|
||||
}
|
||||
|
||||
|
||||
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy/*=false*/)
|
||||
{
|
||||
static char const s_gamefunc_[] = "gamefunc_";
|
||||
|
@ -338,6 +366,9 @@ void CONFIG_SetDefaults(void)
|
|||
CONTROL_MapAnalogAxis(i, ud.config.MouseAnalogueAxes[i], controldevice_mouse);
|
||||
}
|
||||
|
||||
#if !defined GEKKO
|
||||
CONFIG_SetGameControllerDefaultsStandard();
|
||||
#else
|
||||
for (int i=0; i<MAXJOYBUTTONSANDHATS; i++)
|
||||
{
|
||||
ud.config.JoystickFunctions[i][0] = CONFIG_FunctionNameToNum(joystickdefaults[i]);
|
||||
|
@ -361,6 +392,7 @@ void CONFIG_SetDefaults(void)
|
|||
ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(joystickanalogdefaults[i]);
|
||||
CONTROL_MapAnalogAxis(i, ud.config.JoystickAnalogueAxes[i], controldevice_joystick);
|
||||
}
|
||||
#endif
|
||||
|
||||
VM_OnEvent(EVENT_SETDEFAULTS, g_player[myconnectindex].ps->i, myconnectindex);
|
||||
}
|
||||
|
@ -544,6 +576,187 @@ void CONFIG_SetupJoystick(void)
|
|||
}
|
||||
}
|
||||
|
||||
struct GameControllerButtonSetting
|
||||
{
|
||||
GameControllerButton button;
|
||||
int function;
|
||||
|
||||
void apply() const
|
||||
{
|
||||
CONFIG_SetJoystickButtonFunction(button, 0, function);
|
||||
}
|
||||
};
|
||||
struct GameControllerAnalogAxisSetting
|
||||
{
|
||||
GameControllerAxis axis;
|
||||
int function;
|
||||
|
||||
void apply() const
|
||||
{
|
||||
CONFIG_SetJoystickAnalogAxisFunction(axis, function);
|
||||
}
|
||||
};
|
||||
struct GameControllerDigitalAxisSetting
|
||||
{
|
||||
GameControllerAxis axis;
|
||||
int polarity;
|
||||
int function;
|
||||
|
||||
void apply() const
|
||||
{
|
||||
CONFIG_SetJoystickDigitalAxisFunction(axis, polarity, function);
|
||||
}
|
||||
};
|
||||
|
||||
static void CONFIG_SetGameControllerAxesModern()
|
||||
{
|
||||
static GameControllerAnalogAxisSetting const analogAxes[] =
|
||||
{
|
||||
{ GAMECONTROLLER_AXIS_LEFTX, analog_strafing },
|
||||
{ GAMECONTROLLER_AXIS_LEFTY, analog_moving },
|
||||
{ GAMECONTROLLER_AXIS_RIGHTX, analog_turning },
|
||||
{ GAMECONTROLLER_AXIS_RIGHTY, analog_lookingupanddown },
|
||||
};
|
||||
|
||||
for (auto const & analogAxis : analogAxes)
|
||||
analogAxis.apply();
|
||||
}
|
||||
|
||||
void CONFIG_SetGameControllerDefaultsStandard()
|
||||
{
|
||||
CONFIG_SetGameControllerDefaultsClear();
|
||||
CONFIG_SetGameControllerAxesModern();
|
||||
|
||||
static GameControllerButtonSetting const buttons[] =
|
||||
{
|
||||
{ GAMECONTROLLER_BUTTON_A, gamefunc_Jump },
|
||||
{ GAMECONTROLLER_BUTTON_X, gamefunc_Open },
|
||||
{ GAMECONTROLLER_BUTTON_Y, gamefunc_Quick_Kick },
|
||||
{ GAMECONTROLLER_BUTTON_BACK, gamefunc_Map },
|
||||
{ GAMECONTROLLER_BUTTON_LEFTSTICK, gamefunc_Run },
|
||||
{ GAMECONTROLLER_BUTTON_RIGHTSTICK, gamefunc_Crouch },
|
||||
{ GAMECONTROLLER_BUTTON_LEFTSHOULDER, gamefunc_Crouch },
|
||||
{ GAMECONTROLLER_BUTTON_RIGHTSHOULDER, gamefunc_Jump },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_UP, gamefunc_Previous_Weapon },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_DOWN, gamefunc_Next_Weapon },
|
||||
};
|
||||
|
||||
static GameControllerButtonSetting const dukebuttons[] =
|
||||
{
|
||||
{ GAMECONTROLLER_BUTTON_B, gamefunc_Inventory },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_LEFT, gamefunc_Inventory_Left },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_RIGHT, gamefunc_Inventory_Right },
|
||||
};
|
||||
|
||||
static GameControllerButtonSetting const furybuttons[] =
|
||||
{
|
||||
{ GAMECONTROLLER_BUTTON_B, gamefunc_Steroids },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_LEFT, gamefunc_MedKit },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_RIGHT, gamefunc_NightVision },
|
||||
};
|
||||
|
||||
for (auto const & button : buttons)
|
||||
button.apply();
|
||||
|
||||
if (FURY)
|
||||
{
|
||||
for (auto const & button : furybuttons)
|
||||
button.apply();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto const & button : dukebuttons)
|
||||
button.apply();
|
||||
}
|
||||
|
||||
static GameControllerDigitalAxisSetting const digitalAxes[] =
|
||||
{
|
||||
{ GAMECONTROLLER_AXIS_TRIGGERLEFT, 1, gamefunc_Alt_Fire },
|
||||
{ GAMECONTROLLER_AXIS_TRIGGERRIGHT, 1, gamefunc_Fire },
|
||||
};
|
||||
|
||||
for (auto const & digitalAxis : digitalAxes)
|
||||
digitalAxis.apply();
|
||||
}
|
||||
|
||||
void CONFIG_SetGameControllerDefaultsPro()
|
||||
{
|
||||
CONFIG_SetGameControllerDefaultsClear();
|
||||
CONFIG_SetGameControllerAxesModern();
|
||||
|
||||
static GameControllerButtonSetting const buttons[] =
|
||||
{
|
||||
{ GAMECONTROLLER_BUTTON_A, gamefunc_Open },
|
||||
{ GAMECONTROLLER_BUTTON_B, gamefunc_Quick_Kick },
|
||||
{ GAMECONTROLLER_BUTTON_Y, gamefunc_Third_Person_View },
|
||||
{ GAMECONTROLLER_BUTTON_BACK, gamefunc_Map },
|
||||
{ GAMECONTROLLER_BUTTON_LEFTSTICK, gamefunc_Run },
|
||||
{ GAMECONTROLLER_BUTTON_RIGHTSTICK, gamefunc_Crouch },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_UP, gamefunc_Previous_Weapon },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_DOWN, gamefunc_Next_Weapon },
|
||||
};
|
||||
|
||||
static GameControllerButtonSetting const dukebuttons[] =
|
||||
{
|
||||
{ GAMECONTROLLER_BUTTON_X, gamefunc_Inventory },
|
||||
{ GAMECONTROLLER_BUTTON_LEFTSHOULDER, gamefunc_Previous_Weapon },
|
||||
{ GAMECONTROLLER_BUTTON_RIGHTSHOULDER, gamefunc_Next_Weapon },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_LEFT, gamefunc_Inventory_Left },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_RIGHT, gamefunc_Inventory_Right },
|
||||
};
|
||||
|
||||
static GameControllerButtonSetting const furybuttons[] =
|
||||
{
|
||||
{ GAMECONTROLLER_BUTTON_X, gamefunc_Steroids },
|
||||
{ GAMECONTROLLER_BUTTON_LEFTSHOULDER, gamefunc_Crouch },
|
||||
{ GAMECONTROLLER_BUTTON_RIGHTSHOULDER, gamefunc_Alt_Fire },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_LEFT, gamefunc_MedKit },
|
||||
{ GAMECONTROLLER_BUTTON_DPAD_RIGHT, gamefunc_NightVision },
|
||||
};
|
||||
|
||||
for (auto const & button : buttons)
|
||||
button.apply();
|
||||
|
||||
if (FURY)
|
||||
{
|
||||
for (auto const & button : furybuttons)
|
||||
button.apply();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto const & button : dukebuttons)
|
||||
button.apply();
|
||||
}
|
||||
|
||||
static GameControllerDigitalAxisSetting const digitalAxes[] =
|
||||
{
|
||||
{ GAMECONTROLLER_AXIS_TRIGGERLEFT, 1, gamefunc_Jump },
|
||||
{ GAMECONTROLLER_AXIS_TRIGGERRIGHT, 1, gamefunc_Fire },
|
||||
};
|
||||
|
||||
for (auto const & digitalAxis : digitalAxes)
|
||||
digitalAxis.apply();
|
||||
}
|
||||
|
||||
void CONFIG_SetGameControllerDefaultsClear()
|
||||
{
|
||||
for (int i=0; i<MAXJOYBUTTONSANDHATS; i++)
|
||||
{
|
||||
CONFIG_SetJoystickButtonFunction(i, 0, -1);
|
||||
CONFIG_SetJoystickButtonFunction(i, 1, -1);
|
||||
}
|
||||
|
||||
for (int i=0; i<MAXJOYAXES; i++)
|
||||
{
|
||||
CONFIG_SetJoystickAnalogAxisScale(i, DEFAULTJOYSTICKANALOGUESCALE);
|
||||
CONFIG_SetJoystickAnalogAxisDeadSaturate(i, DEFAULTJOYSTICKANALOGUEDEAD, DEFAULTJOYSTICKANALOGUESATURATE);
|
||||
|
||||
CONFIG_SetJoystickDigitalAxisFunction(i, 0, -1);
|
||||
CONFIG_SetJoystickDigitalAxisFunction(i, 1, -1);
|
||||
|
||||
CONFIG_SetJoystickAnalogAxisFunction(i, -1);
|
||||
}
|
||||
}
|
||||
|
||||
int CONFIG_ReadSetup(void)
|
||||
{
|
||||
|
|
|
@ -32,6 +32,10 @@ void CONFIG_SetupMouse(void);
|
|||
void CONFIG_SetupJoystick(void);
|
||||
void CONFIG_SetDefaultKeys(const char (*keyptr)[MAXGAMEFUNCLEN], bool lazy=false);
|
||||
|
||||
void CONFIG_SetGameControllerDefaultsStandard(void);
|
||||
void CONFIG_SetGameControllerDefaultsPro(void);
|
||||
void CONFIG_SetGameControllerDefaultsClear(void);
|
||||
|
||||
int32_t CONFIG_GetMapBestTime(char const *mapname, uint8_t const *mapmd4);
|
||||
int CONFIG_SetMapBestTime(uint8_t const *mapmd4, int32_t tm);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ extern "C" {
|
|||
#define DEFAULTJOYSTICKANALOGUESATURATE 9500
|
||||
#else
|
||||
#define DEFAULTJOYSTICKANALOGUESCALE 65536
|
||||
#define DEFAULTJOYSTICKANALOGUEDEAD 1000
|
||||
#define DEFAULTJOYSTICKANALOGUEDEAD 2000
|
||||
#define DEFAULTJOYSTICKANALOGUESATURATE 9500
|
||||
#endif
|
||||
|
||||
|
|
|
@ -32,48 +32,42 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
int32_t I_CheckAllInput(void)
|
||||
{
|
||||
return (
|
||||
return
|
||||
KB_KeyWaiting()
|
||||
|| MOUSE_GetButtons()
|
||||
|| JOYSTICK_GetButtons()
|
||||
#if defined EDUKE32_IOS
|
||||
g_mouseClickState == MOUSE_PRESSED ||
|
||||
|| g_mouseClickState == MOUSE_PRESSED
|
||||
#endif
|
||||
KB_KeyWaiting() ||
|
||||
MOUSE_GetButtons() ||
|
||||
JOYSTICK_GetButtons()
|
||||
);
|
||||
;
|
||||
}
|
||||
void I_ClearAllInput(void)
|
||||
{
|
||||
#if defined EDUKE32_IOS
|
||||
mouseAdvanceClickState();
|
||||
#endif
|
||||
KB_FlushKeyboardQueue();
|
||||
KB_ClearKeysDown();
|
||||
MOUSE_ClearAllButtons();
|
||||
JOYSTICK_ClearAllButtons();
|
||||
CONTROL_ClearAllButtons();
|
||||
#if defined EDUKE32_IOS
|
||||
mouseAdvanceClickState();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int32_t I_AdvanceTrigger(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_Space) ||
|
||||
KB_KeyPressed(sc_kpad_Enter) ||
|
||||
KB_KeyPressed(sc_Enter) ||
|
||||
return
|
||||
KB_KeyPressed(sc_Enter)
|
||||
|| KB_KeyPressed(sc_kpad_Enter)
|
||||
|| KB_KeyPressed(sc_Space)
|
||||
#if !defined EDUKE32_TOUCH_DEVICES
|
||||
MOUSEINACTIVECONDITIONAL(MOUSE_GetButtons()&LEFT_MOUSE) ||
|
||||
|| MOUSEINACTIVECONDITIONAL(MOUSE_GetButtons()&LEFT_MOUSE)
|
||||
#endif
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<SDL_CONTROLLER_BUTTON_A))
|
||||
#if defined(GEKKO)
|
||||
MOUSEINACTIVECONDITIONAL(JOYSTICK_GetButtons()&WII_A)
|
||||
#else
|
||||
BUTTON(gamefunc_Open) ||
|
||||
# if !defined EDUKE32_TOUCH_DEVICES
|
||||
MOUSEINACTIVECONDITIONAL(BUTTON(gamefunc_Fire))
|
||||
# else
|
||||
BUTTON(gamefunc_Fire)
|
||||
# endif
|
||||
|| MOUSEINACTIVECONDITIONAL(JOYSTICK_GetButtons()&WII_A)
|
||||
#endif
|
||||
);
|
||||
;
|
||||
}
|
||||
|
||||
void I_AdvanceTriggerClear(void)
|
||||
|
@ -83,24 +77,22 @@ void I_AdvanceTriggerClear(void)
|
|||
KB_ClearKeyDown(sc_kpad_Enter);
|
||||
KB_ClearKeyDown(sc_Enter);
|
||||
MOUSE_ClearButton(LEFT_MOUSE);
|
||||
JOYSTICK_ClearGameControllerButton(1<<SDL_CONTROLLER_BUTTON_A);
|
||||
#if defined(GEKKO)
|
||||
JOYSTICK_ClearButton(WII_A);
|
||||
#else
|
||||
CONTROL_ClearButton(gamefunc_Open);
|
||||
CONTROL_ClearButton(gamefunc_Fire);
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t I_ReturnTrigger(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_Escape) ||
|
||||
(MOUSE_GetButtons()&RIGHT_MOUSE) ||
|
||||
BUTTON(gamefunc_Crouch)
|
||||
return
|
||||
KB_KeyPressed(sc_Escape)
|
||||
|| (MOUSE_GetButtons()&RIGHT_MOUSE)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<SDL_CONTROLLER_BUTTON_B))
|
||||
#if defined(GEKKO)
|
||||
|| (JOYSTICK_GetButtons()&(WII_B|WII_HOME))
|
||||
|| (JOYSTICK_GetButtons()&(WII_B|WII_HOME))
|
||||
#endif
|
||||
);
|
||||
;
|
||||
}
|
||||
|
||||
void I_ReturnTriggerClear(void)
|
||||
|
@ -108,7 +100,7 @@ void I_ReturnTriggerClear(void)
|
|||
KB_FlushKeyboardQueue();
|
||||
KB_ClearKeyDown(sc_Escape);
|
||||
MOUSE_ClearButton(RIGHT_MOUSE);
|
||||
CONTROL_ClearButton(gamefunc_Crouch);
|
||||
JOYSTICK_ClearGameControllerButton(1<<SDL_CONTROLLER_BUTTON_B);
|
||||
#if defined(GEKKO)
|
||||
JOYSTICK_ClearButton(WII_B);
|
||||
JOYSTICK_ClearButton(WII_HOME);
|
||||
|
@ -117,30 +109,51 @@ void I_ReturnTriggerClear(void)
|
|||
|
||||
int32_t I_GeneralTrigger(void)
|
||||
{
|
||||
return I_AdvanceTrigger() || I_ReturnTrigger();
|
||||
return
|
||||
I_AdvanceTrigger()
|
||||
|| I_ReturnTrigger()
|
||||
#if !defined GEKKO
|
||||
|| BUTTON(gamefunc_Open)
|
||||
# if !defined EDUKE32_TOUCH_DEVICES
|
||||
|| MOUSEINACTIVECONDITIONAL(BUTTON(gamefunc_Fire))
|
||||
# else
|
||||
|| BUTTON(gamefunc_Fire)
|
||||
# endif
|
||||
#endif
|
||||
|| BUTTON(gamefunc_Crouch)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START))
|
||||
;
|
||||
}
|
||||
|
||||
void I_GeneralTriggerClear(void)
|
||||
{
|
||||
I_AdvanceTriggerClear();
|
||||
I_ReturnTriggerClear();
|
||||
#if !defined GEKKO
|
||||
CONTROL_ClearButton(gamefunc_Open);
|
||||
CONTROL_ClearButton(gamefunc_Fire);
|
||||
#endif
|
||||
CONTROL_ClearButton(gamefunc_Crouch);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_START);
|
||||
}
|
||||
|
||||
|
||||
int32_t I_EscapeTrigger(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_Escape)
|
||||
return
|
||||
KB_KeyPressed(sc_Escape)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_START))
|
||||
#if defined(GEKKO)
|
||||
|| (JOYSTICK_GetButtons()&WII_HOME)
|
||||
|| (JOYSTICK_GetButtons()&WII_HOME)
|
||||
#endif
|
||||
);
|
||||
;
|
||||
}
|
||||
|
||||
void I_EscapeTriggerClear(void)
|
||||
{
|
||||
KB_FlushKeyboardQueue();
|
||||
KB_ClearKeyDown(sc_Escape);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_START);
|
||||
#if defined(GEKKO)
|
||||
JOYSTICK_ClearButton(WII_HOME);
|
||||
#endif
|
||||
|
@ -149,13 +162,14 @@ void I_EscapeTriggerClear(void)
|
|||
|
||||
int32_t I_MenuUp(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_UpArrow) ||
|
||||
KB_KeyPressed(sc_kpad_8) ||
|
||||
(MOUSE_GetButtons()&WHEELUP_MOUSE) ||
|
||||
BUTTON(gamefunc_Move_Forward) ||
|
||||
(JOYSTICK_GetHat(0)&HAT_UP)
|
||||
);
|
||||
return
|
||||
KB_KeyPressed(sc_UpArrow)
|
||||
|| KB_KeyPressed(sc_kpad_8)
|
||||
|| (MOUSE_GetButtons()&WHEELUP_MOUSE)
|
||||
|| BUTTON(gamefunc_Move_Forward)
|
||||
|| (JOYSTICK_GetHat(0)&HAT_UP)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_UP))
|
||||
;
|
||||
}
|
||||
|
||||
void I_MenuUpClear(void)
|
||||
|
@ -165,18 +179,20 @@ void I_MenuUpClear(void)
|
|||
MOUSE_ClearButton(WHEELUP_MOUSE);
|
||||
CONTROL_ClearButton(gamefunc_Move_Forward);
|
||||
JOYSTICK_ClearHat(0);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_UP);
|
||||
}
|
||||
|
||||
|
||||
int32_t I_MenuDown(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_DownArrow) ||
|
||||
KB_KeyPressed(sc_kpad_2) ||
|
||||
(MOUSE_GetButtons()&WHEELDOWN_MOUSE) ||
|
||||
BUTTON(gamefunc_Move_Backward) ||
|
||||
(JOYSTICK_GetHat(0)&HAT_DOWN)
|
||||
);
|
||||
return
|
||||
KB_KeyPressed(sc_DownArrow)
|
||||
|| KB_KeyPressed(sc_kpad_2)
|
||||
|| (MOUSE_GetButtons()&WHEELDOWN_MOUSE)
|
||||
|| BUTTON(gamefunc_Move_Backward)
|
||||
|| (JOYSTICK_GetHat(0)&HAT_DOWN)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN))
|
||||
;
|
||||
}
|
||||
|
||||
void I_MenuDownClear(void)
|
||||
|
@ -187,19 +203,21 @@ void I_MenuDownClear(void)
|
|||
MOUSE_ClearButton(WHEELDOWN_MOUSE);
|
||||
CONTROL_ClearButton(gamefunc_Move_Backward);
|
||||
JOYSTICK_ClearHat(0);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_DOWN);
|
||||
}
|
||||
|
||||
|
||||
int32_t I_MenuLeft(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_LeftArrow) ||
|
||||
KB_KeyPressed(sc_kpad_4) ||
|
||||
(SHIFTS_IS_PRESSED && KB_KeyPressed(sc_Tab)) ||
|
||||
BUTTON(gamefunc_Turn_Left) ||
|
||||
BUTTON(gamefunc_Strafe_Left) ||
|
||||
(JOYSTICK_GetHat(0)&HAT_LEFT)
|
||||
);
|
||||
return
|
||||
KB_KeyPressed(sc_LeftArrow)
|
||||
|| KB_KeyPressed(sc_kpad_4)
|
||||
|| (SHIFTS_IS_PRESSED && KB_KeyPressed(sc_Tab))
|
||||
|| BUTTON(gamefunc_Turn_Left)
|
||||
|| BUTTON(gamefunc_Strafe_Left)
|
||||
|| (JOYSTICK_GetHat(0)&HAT_LEFT)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT))
|
||||
;
|
||||
}
|
||||
|
||||
void I_MenuLeftClear(void)
|
||||
|
@ -210,20 +228,22 @@ void I_MenuLeftClear(void)
|
|||
CONTROL_ClearButton(gamefunc_Turn_Left);
|
||||
CONTROL_ClearButton(gamefunc_Strafe_Left);
|
||||
JOYSTICK_ClearHat(0);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_LEFT);
|
||||
}
|
||||
|
||||
|
||||
int32_t I_MenuRight(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_RightArrow) ||
|
||||
KB_KeyPressed(sc_kpad_6) ||
|
||||
(!SHIFTS_IS_PRESSED && KB_KeyPressed(sc_Tab)) ||
|
||||
BUTTON(gamefunc_Turn_Right) ||
|
||||
BUTTON(gamefunc_Strafe_Right) ||
|
||||
(MOUSE_GetButtons()&MIDDLE_MOUSE) ||
|
||||
(JOYSTICK_GetHat(0)&HAT_RIGHT)
|
||||
);
|
||||
return
|
||||
KB_KeyPressed(sc_RightArrow)
|
||||
|| KB_KeyPressed(sc_kpad_6)
|
||||
|| (!SHIFTS_IS_PRESSED && KB_KeyPressed(sc_Tab))
|
||||
|| BUTTON(gamefunc_Turn_Right)
|
||||
|| BUTTON(gamefunc_Strafe_Right)
|
||||
|| (MOUSE_GetButtons()&MIDDLE_MOUSE)
|
||||
|| (JOYSTICK_GetHat(0)&HAT_RIGHT)
|
||||
|| (JOYSTICK_GetGameControllerButtons()&(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT))
|
||||
;
|
||||
}
|
||||
|
||||
void I_MenuRightClear(void)
|
||||
|
@ -235,53 +255,54 @@ void I_MenuRightClear(void)
|
|||
CONTROL_ClearButton(gamefunc_Strafe_Right);
|
||||
MOUSE_ClearButton(MIDDLE_MOUSE);
|
||||
JOYSTICK_ClearHat(0);
|
||||
JOYSTICK_ClearGameControllerButton(1<<GAMECONTROLLER_BUTTON_DPAD_RIGHT);
|
||||
}
|
||||
|
||||
|
||||
int32_t I_PanelUp(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_PgUp) ||
|
||||
I_MenuUp() ||
|
||||
I_MenuLeft()
|
||||
);
|
||||
return
|
||||
I_MenuUp()
|
||||
|| I_MenuLeft()
|
||||
|| KB_KeyPressed(sc_PgUp)
|
||||
;
|
||||
}
|
||||
|
||||
void I_PanelUpClear(void)
|
||||
{
|
||||
KB_ClearKeyDown(sc_PgUp);
|
||||
I_MenuUpClear();
|
||||
I_MenuLeftClear();
|
||||
KB_ClearKeyDown(sc_PgUp);
|
||||
}
|
||||
|
||||
|
||||
int32_t I_PanelDown(void)
|
||||
{
|
||||
return (
|
||||
KB_KeyPressed(sc_PgDn) ||
|
||||
I_MenuDown() ||
|
||||
I_MenuRight() ||
|
||||
I_AdvanceTrigger()
|
||||
);
|
||||
return
|
||||
I_MenuDown()
|
||||
|| I_MenuRight()
|
||||
|| KB_KeyPressed(sc_PgDn)
|
||||
|| I_AdvanceTrigger()
|
||||
;
|
||||
}
|
||||
|
||||
void I_PanelDownClear(void)
|
||||
{
|
||||
KB_ClearKeyDown(sc_PgDn);
|
||||
I_MenuDownClear();
|
||||
I_MenuRightClear();
|
||||
KB_ClearKeyDown(sc_PgDn);
|
||||
I_AdvanceTriggerClear();
|
||||
}
|
||||
|
||||
|
||||
int32_t I_SliderLeft(void)
|
||||
{
|
||||
return (
|
||||
return
|
||||
I_MenuLeft()
|
||||
#if !defined EDUKE32_TOUCH_DEVICES
|
||||
MOUSEINACTIVECONDITIONAL((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELUP_MOUSE)) ||
|
||||
|| MOUSEINACTIVECONDITIONAL((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELUP_MOUSE))
|
||||
#endif
|
||||
I_MenuLeft()
|
||||
);
|
||||
;
|
||||
}
|
||||
|
||||
void I_SliderLeftClear(void)
|
||||
|
@ -293,12 +314,12 @@ void I_SliderLeftClear(void)
|
|||
|
||||
int32_t I_SliderRight(void)
|
||||
{
|
||||
return (
|
||||
return
|
||||
I_MenuRight()
|
||||
#if !defined EDUKE32_TOUCH_DEVICES
|
||||
MOUSEINACTIVECONDITIONAL((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELDOWN_MOUSE)) ||
|
||||
|| MOUSEINACTIVECONDITIONAL((MOUSE_GetButtons()&LEFT_MOUSE) && (MOUSE_GetButtons()&WHEELDOWN_MOUSE))
|
||||
#endif
|
||||
I_MenuRight()
|
||||
);
|
||||
;
|
||||
}
|
||||
|
||||
void I_SliderRightClear(void)
|
||||
|
|
|
@ -238,6 +238,7 @@ static MenuEntryFormat_t MEF_OptionsMenu = { 7<<16, 0, 0 };
|
|||
static MenuEntryFormat_t MEF_CenterMenu = { 7<<16, 0, 0 };
|
||||
static MenuEntryFormat_t MEF_BigOptions_Apply = { 4<<16, 16<<16, -(260<<16) };
|
||||
static MenuEntryFormat_t MEF_BigOptionsRt = { 4<<16, 0, -(260<<16) };
|
||||
static MenuEntryFormat_t MEF_BigOptionsRtSections = { 3<<16, 0, -(260<<16) };
|
||||
#if defined USE_OPENGL || !defined EDUKE32_ANDROID_MENU
|
||||
static MenuEntryFormat_t MEF_SmallOptions = { 1<<16, 0, -(260<<16) };
|
||||
#endif
|
||||
|
@ -480,12 +481,12 @@ MAKE_MENU_TOP_ENTRYLINK( "Player Setup", MEF_OptionsMenu, OPTIONS_PLAYERSETUP, M
|
|||
#ifndef EDUKE32_ANDROID_MENU
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Control Setup", MEF_OptionsMenu, OPTIONS_CONTROLS, MENU_CONTROLS );
|
||||
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Keyboard Setup", MEF_BigOptionsRt, OPTIONS_KEYBOARDSETUP, MENU_KEYBOARDSETUP );
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Mouse Setup", MEF_BigOptionsRt, OPTIONS_MOUSESETUP, MENU_MOUSESETUP );
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Keyboard Setup", MEF_BigOptionsRtSections, OPTIONS_KEYBOARDSETUP, MENU_KEYBOARDSETUP );
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Mouse Setup", MEF_BigOptionsRtSections, OPTIONS_MOUSESETUP, MENU_MOUSESETUP );
|
||||
#endif
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Joystick Setup", MEF_BigOptionsRt, OPTIONS_JOYSTICKSETUP, MENU_JOYSTICKSETUP );
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Joystick Setup", MEF_BigOptionsRtSections, OPTIONS_JOYSTICKSETUP, MENU_JOYSTICKSETUP );
|
||||
#ifdef EDUKE32_ANDROID_MENU
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Touch Setup", MEF_BigOptionsRt, OPTIONS_TOUCHSETUP, MENU_TOUCHSETUP );
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Touch Setup", MEF_BigOptionsRtSections, OPTIONS_TOUCHSETUP, MENU_TOUCHSETUP );
|
||||
#endif
|
||||
#ifdef EDUKE32_SIMPLE_MENU
|
||||
MAKE_MENU_TOP_ENTRYLINK("Cheats", MEF_OptionsMenu, OPTIONS_CHEATS, MENU_CHEATS);
|
||||
|
@ -716,9 +717,9 @@ static MenuEntry_t *MEL_CONTROLS[] = {
|
|||
&ME_OPTIONS_MOUSESETUP,
|
||||
&ME_OPTIONS_JOYSTICKSETUP,
|
||||
#else
|
||||
&ME_OPTIONS_TOUCHSETUP
|
||||
&ME_OPTIONS_TOUCHSETUP,
|
||||
#endif
|
||||
&ME_Space2_Redfont,
|
||||
&ME_Space6_Redfont,
|
||||
&ME_GAMESETUP_AIM_AUTO,
|
||||
};
|
||||
|
||||
|
@ -945,12 +946,20 @@ static MenuEntry_t *MEL_TOUCHSENS [] = {
|
|||
};
|
||||
#endif
|
||||
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Edit Buttons", MEF_CenterMenu, JOYSTICK_EDITBUTTONS, MENU_JOYSTICKBTNS );
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Edit Axes", MEF_CenterMenu, JOYSTICK_EDITAXES, MENU_JOYSTICKAXES );
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Edit Buttons", MEF_BigOptionsRtSections, JOYSTICK_EDITBUTTONS, MENU_JOYSTICKBTNS );
|
||||
MAKE_MENU_TOP_ENTRYLINK( "Edit Axes", MEF_BigOptionsRtSections, JOYSTICK_EDITAXES, MENU_JOYSTICKAXES );
|
||||
|
||||
static MenuEntry_t ME_JOYSTICK_DEFAULTS_STANDARD = MAKE_MENUENTRY( "Use Standard Layout", &MF_Redfont, &MEF_BigOptionsRtSections, &MEO_NULL, Link );
|
||||
static MenuEntry_t ME_JOYSTICK_DEFAULTS_PRO = MAKE_MENUENTRY( "Use Pro Layout", &MF_Redfont, &MEF_BigOptionsRtSections, &MEO_NULL, Link );
|
||||
static MenuEntry_t ME_JOYSTICK_DEFAULTS_CLEAR = MAKE_MENUENTRY( "Clear All Settings", &MF_Redfont, &MEF_BigOptionsRtSections, &MEO_NULL, Link );
|
||||
|
||||
static MenuEntry_t *MEL_JOYSTICKSETUP[] = {
|
||||
&ME_JOYSTICK_EDITBUTTONS,
|
||||
&ME_JOYSTICK_EDITAXES,
|
||||
&ME_Space6_Redfont,
|
||||
&ME_JOYSTICK_DEFAULTS_STANDARD,
|
||||
&ME_JOYSTICK_DEFAULTS_PRO,
|
||||
&ME_JOYSTICK_DEFAULTS_CLEAR,
|
||||
};
|
||||
|
||||
#define MAXJOYBUTTONSTRINGLENGTH 32
|
||||
|
@ -1353,7 +1362,7 @@ static MenuMenu_t M_TOUCHSETUP = MAKE_MENUMENU( "Touch Setup", &MMF_Top_Options,
|
|||
static MenuMenu_t M_TOUCHSENS = MAKE_MENUMENU( "Sensitivity", &MMF_BigOptions, MEL_TOUCHSENS);
|
||||
static MenuPanel_t M_TOUCHBUTTONS = { "Button Setup", MENU_TOUCHSETUP, MA_Return, MENU_TOUCHSETUP, MA_Advance, };
|
||||
#endif
|
||||
static MenuMenu_t M_JOYSTICKSETUP = MAKE_MENUMENU( "Joystick Setup", &MMF_Top_Joystick_Network, MEL_JOYSTICKSETUP );
|
||||
static MenuMenu_t M_JOYSTICKSETUP = MAKE_MENUMENU( "Joystick Setup", &MMF_BigOptions, MEL_JOYSTICKSETUP );
|
||||
static MenuMenu_t M_JOYSTICKBTNS = MAKE_MENUMENU( "Joystick Buttons", &MMF_MouseJoySetupBtns, MEL_JOYSTICKBTNS );
|
||||
static MenuMenu_t M_JOYSTICKAXES = MAKE_MENUMENU( "Joystick Axes", &MMF_BigSliders, MEL_JOYSTICKAXES );
|
||||
static MenuMenu_t M_KEYBOARDKEYS = MAKE_MENUMENU( "Key Configuration", &MMF_KeyboardSetupFuncs, MEL_KEYBOARDSETUPFUNCS );
|
||||
|
@ -2091,6 +2100,11 @@ static void Menu_Pre(MenuID_t cm)
|
|||
MenuEntry_DisableOnCondition(&ME_SAVESETUP_MAXAUTOSAVES, !ud.autosavedeletion);
|
||||
break;
|
||||
|
||||
case MENU_JOYSTICKSETUP:
|
||||
MenuEntry_DisableOnCondition(&ME_JOYSTICK_DEFAULTS_STANDARD, !joystick.isGameController);
|
||||
MenuEntry_DisableOnCondition(&ME_JOYSTICK_DEFAULTS_PRO, !joystick.isGameController);
|
||||
break;
|
||||
|
||||
#ifndef EDUKE32_SIMPLE_MENU
|
||||
case MENU_MOUSESETUP:
|
||||
MenuEntry_DisableOnCondition(&ME_MOUSESETUP_MOUSEAIMING, ud.mouseaiming);
|
||||
|
@ -3122,6 +3136,15 @@ static void Menu_EntryLinkActivate(MenuEntry_t *entry)
|
|||
break;
|
||||
}
|
||||
|
||||
case MENU_JOYSTICKSETUP:
|
||||
if (entry == &ME_JOYSTICK_DEFAULTS_STANDARD)
|
||||
CONFIG_SetGameControllerDefaultsStandard();
|
||||
else if (entry == &ME_JOYSTICK_DEFAULTS_PRO)
|
||||
CONFIG_SetGameControllerDefaultsPro();
|
||||
else if (entry == &ME_JOYSTICK_DEFAULTS_CLEAR)
|
||||
CONFIG_SetGameControllerDefaultsClear();
|
||||
break;
|
||||
|
||||
case MENU_JOYSTICKAXES:
|
||||
M_JOYSTICKAXIS.title = joyGetName(0, M_JOYSTICKAXES.currentEntry);
|
||||
MEO_JOYSTICKAXIS_ANALOG.data = &ud.config.JoystickAnalogueAxes[M_JOYSTICKAXES.currentEntry];
|
||||
|
|
|
@ -55,8 +55,8 @@ extern "C" {
|
|||
#define BUTTONUNDEFINED 0x7f
|
||||
#define KEYUNDEFINED 0x7f
|
||||
|
||||
#define THRESHOLD 0x200
|
||||
#define MINTHRESHOLD 0x80
|
||||
#define THRESHOLD (0x200 * 32767 / 10000)
|
||||
#define MINTHRESHOLD (0x80 * 32767 / 10000)
|
||||
|
||||
#define DEFAULTMOUSESENSITIVITY 4 // 0x7000+MINIMUMMOUSESENSITIVITY
|
||||
|
||||
|
|
|
@ -126,6 +126,38 @@ typedef enum
|
|||
controldevice_joystick
|
||||
} controldevice;
|
||||
|
||||
enum GameControllerButton : int
|
||||
{
|
||||
GAMECONTROLLER_BUTTON_INVALID = -1,
|
||||
GAMECONTROLLER_BUTTON_A,
|
||||
GAMECONTROLLER_BUTTON_B,
|
||||
GAMECONTROLLER_BUTTON_X,
|
||||
GAMECONTROLLER_BUTTON_Y,
|
||||
GAMECONTROLLER_BUTTON_BACK,
|
||||
GAMECONTROLLER_BUTTON_GUIDE,
|
||||
GAMECONTROLLER_BUTTON_START,
|
||||
GAMECONTROLLER_BUTTON_LEFTSTICK,
|
||||
GAMECONTROLLER_BUTTON_RIGHTSTICK,
|
||||
GAMECONTROLLER_BUTTON_LEFTSHOULDER,
|
||||
GAMECONTROLLER_BUTTON_RIGHTSHOULDER,
|
||||
GAMECONTROLLER_BUTTON_DPAD_UP,
|
||||
GAMECONTROLLER_BUTTON_DPAD_DOWN,
|
||||
GAMECONTROLLER_BUTTON_DPAD_LEFT,
|
||||
GAMECONTROLLER_BUTTON_DPAD_RIGHT,
|
||||
GAMECONTROLLER_BUTTON_MAX
|
||||
};
|
||||
|
||||
enum GameControllerAxis : int
|
||||
{
|
||||
GAMECONTROLLER_AXIS_INVALID = -1,
|
||||
GAMECONTROLLER_AXIS_LEFTX,
|
||||
GAMECONTROLLER_AXIS_LEFTY,
|
||||
GAMECONTROLLER_AXIS_RIGHTX,
|
||||
GAMECONTROLLER_AXIS_RIGHTY,
|
||||
GAMECONTROLLER_AXIS_TRIGGERLEFT,
|
||||
GAMECONTROLLER_AXIS_TRIGGERRIGHT,
|
||||
GAMECONTROLLER_AXIS_MAX
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
//
|
||||
|
|
|
@ -39,7 +39,9 @@ extern "C" {
|
|||
#define HAT_LEFTDOWN (HAT_LEFT|HAT_DOWN)
|
||||
|
||||
int32_t JOYSTICK_GetButtons( void );
|
||||
int32_t JOYSTICK_GetGameControllerButtons( void );
|
||||
int32_t JOYSTICK_ClearButton( int32_t b );
|
||||
void JOYSTICK_ClearGameControllerButton( int32_t b );
|
||||
void JOYSTICK_ClearAllButtons( void );
|
||||
|
||||
int32_t JOYSTICK_GetHat( int32_t h );
|
||||
|
|
|
@ -55,10 +55,26 @@ int32_t JOYSTICK_GetButtons(void)
|
|||
|
||||
return buttons;
|
||||
}
|
||||
int32_t JOYSTICK_GetGameControllerButtons(void)
|
||||
{
|
||||
if (!joystick.isGameController)
|
||||
return 0;
|
||||
|
||||
int32_t buttons;
|
||||
joyReadButtons(&buttons);
|
||||
return buttons;
|
||||
}
|
||||
int32_t JOYSTICK_ClearButton(int32_t b)
|
||||
{
|
||||
return (joystick.bits &= ~b);
|
||||
}
|
||||
void JOYSTICK_ClearGameControllerButton(int32_t b)
|
||||
{
|
||||
if (!joystick.isGameController)
|
||||
return;
|
||||
|
||||
joystick.bits &= ~b;
|
||||
}
|
||||
void JOYSTICK_ClearAllButtons(void)
|
||||
{
|
||||
joystick.bits = 0;
|
||||
|
|
Loading…
Reference in a new issue