Removed static hotkey string array from global header and added an accessor function.

This commit is contained in:
Matthew Budd 2020-05-16 13:16:24 -04:00
parent 26f36da7e7
commit 74923eaccc
4 changed files with 44 additions and 33 deletions

View File

@ -26,6 +26,46 @@
#include <sys/stat.h>
#include <sys/types.h>
static const char* HotkeyStrings[HK_MAX] = {
"CheatMenu",
"BindState",
"LoadLua",
"ToggleBG",
"SaveState",
"FDSSelect",
"LoadState",
"FDSEject",
"VSInsertCoin",
"VSToggleDip",
"MovieToggleFrameDisplay",
"SubtitleDisplay",
"Reset",
"Screenshot",
"Pause",
"DecreaseSpeed",
"IncreaseSpeed",
"FrameAdvance",
"Turbo",
"ToggleInputDisplay",
"ToggleMovieRW",
"MuteCapture",
"Quit",
"FrameAdvanceLagSkip",
"LagCounterDisplay",
"SelectState0", "SelectState1", "SelectState2", "SelectState3",
"SelectState4", "SelectState5", "SelectState6", "SelectState7",
"SelectState8", "SelectState9", "SelectStateNext", "SelectStatePrev",
"VolumeDown", "VolumeUp" };
const char *getHotkeyString( int i )
{
if ( (i>=0) && (i<HK_MAX) )
{
return HotkeyStrings[i];
}
return NULL;
}
/**
* Read a custom pallete from a file and load it into the core.
*/

View File

@ -22,36 +22,7 @@ enum HOTKEY { HK_CHEAT_MENU=0, HK_BIND_STATE, HK_LOAD_LUA, HK_TOGGLE_BG,
HK_SELECT_STATE_NEXT, HK_SELECT_STATE_PREV, HK_VOLUME_DOWN, HK_VOLUME_UP,
HK_MAX};
const char *getHotkeyString( int i );
static const char* HotkeyStrings[HK_MAX] = {
"CheatMenu",
"BindState",
"LoadLua",
"ToggleBG",
"SaveState",
"FDSSelect",
"LoadState",
"FDSEject",
"VSInsertCoin",
"VSToggleDip",
"MovieToggleFrameDisplay",
"SubtitleDisplay",
"Reset",
"Screenshot",
"Pause",
"DecreaseSpeed",
"IncreaseSpeed",
"FrameAdvance",
"Turbo",
"ToggleInputDisplay",
"ToggleMovieRW",
"MuteCapture",
"Quit",
"FrameAdvanceLagSkip",
"LagCounterDisplay",
"SelectState0", "SelectState1", "SelectState2", "SelectState3",
"SelectState4", "SelectState5", "SelectState6", "SelectState7",
"SelectState8", "SelectState9", "SelectStateNext", "SelectStatePrev",
"VolumeDown", "VolumeUp" };
#endif

View File

@ -528,7 +528,7 @@ static void hotKeyWindowRefresh (void)
int keycode;
for (int i = 0; i < HK_MAX; i++)
{
std::string optionName = prefix + HotkeyStrings[i];
std::string optionName = prefix + getHotkeyString(i);
g_config->getOption (optionName.c_str (), &keycode);
gtk_tree_store_set (hotkey_store, &iter,
0, optionName.c_str (), 1,
@ -578,7 +578,7 @@ static gint hotKeyPressCB (GtkTreeView * tree, GdkEventKey * event,
{
int sdlkey = 0;
std::string hotKeyName = "SDL.Hotkeys.";
hotKeyName.append (HotkeyStrings[indexArray[0]]);
hotKeyName.append ( getHotkeyString(indexArray[0]) );
// Convert this keypress from GDK to SDL.
#if SDL_VERSION_ATLEAST(2, 0, 0)

View File

@ -183,7 +183,7 @@ setHotKeys (void)
std::string prefix = "SDL.Hotkeys.";
for (int i = 0; i < HK_MAX; i++)
{
g_config->getOption (prefix + HotkeyStrings[i], &Hotkeys[i]);
g_config->getOption (prefix + getHotkeyString(i), &Hotkeys[i]);
}
return;
}