Skip to content

Commit

Permalink
Add NO_KEYBINDINGS for joy mappings
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Sep 18, 2021
1 parent da6e9a5 commit 9b0b0ef
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/eventloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ typedef enum {joyFullscreen,
joyGameshark
} eJoyCommand;

#ifndef NO_KEYBINDINGS
static const char *JoyCmdName[] = { "Joy Mapping Fullscreen",
"Joy Mapping Stop",
"Joy Mapping Pause",
Expand All @@ -139,13 +140,15 @@ static const int NumJoyCommands = sizeof(JoyCmdName) / sizeof(const char *);

static int JoyCmdActive[16][2]; /* if extra joystick commands are added above, make sure there is enough room in this array */
/* [i][0] is Command Active, [i][1] is Hotkey Active */
#endif /* NO_KEYBINDINGS */

static int GamesharkActive = 0;

/*********************************************************************************************************
* static functions for eventloop.c
*/

#ifndef NO_KEYBINDINGS
/** MatchJoyCommand
* This function processes an SDL event and updates the JoyCmdActive array if the
* event matches with the given command.
Expand Down Expand Up @@ -295,13 +298,16 @@ static int MatchJoyCommand(const SDL_Event *event, eJoyCommand cmd)
/* nothing found */
return 0;
}
#endif /* NO_KEYBINDINGS */

/*********************************************************************************************************
* sdl event filter
*/
static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)
{
#ifndef NO_KEYBINDINGS
int cmd, action;
#endif /* NO_KEYBINDINGS */

switch(event->type)
{
Expand Down Expand Up @@ -361,6 +367,7 @@ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)
#endif
#endif

#ifndef NO_KEYBINDINGS
// if joystick action is detected, check if it's mapped to a special function
case SDL_JOYAXISMOTION:
case SDL_JOYBUTTONDOWN:
Expand Down Expand Up @@ -415,6 +422,8 @@ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)

return 0;
break;
#endif /* NO_KEYBINDINGS */

}

return 1; // add this event to SDL queue
Expand All @@ -426,6 +435,7 @@ static int SDLCALL event_sdl_filter(void *userdata, SDL_Event *event)

void event_initialize(void)
{
#ifndef NO_KEYBINDINGS
int i, j;

/* set initial state of all joystick commands to 'off' */
Expand Down Expand Up @@ -492,6 +502,8 @@ void event_initialize(void)
} /* Iterate over comma-separated config phrases */
}
}
#endif /* NO_KEYBINDINGS */


/* set up SDL event filter and disable key repeat */
#if !SDL_VERSION_ATLEAST(2,0,0)
Expand Down

0 comments on commit 9b0b0ef

Please sign in to comment.