Add fast forward hotkeys

This commit is contained in:
Jon Pacheco 2019-05-12 11:41:46 +01:00
parent 99b07f9300
commit 7d2ba09fd7
5 changed files with 58 additions and 10 deletions

View File

@ -26,7 +26,7 @@ namespace Config
typedef struct
{
char Name[16];
char Name[32];
int Type;
void* Value;
int DefaultInt;

View File

@ -58,7 +58,7 @@ char dskeylabels[12][8] = {"A:", "B:", "Select:", "Start:", "Right:", "Left:", "
int identity[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31};
char hotkeylabels[HK_MAX][32] = {"Close/open lid:", "Microphone:"};
char hotkeylabels[HK_MAX][32] = {"Close/open lid:", "Microphone:", "Fast Forward:", "Fast Forward (Toggle):"};
int openedmask;
InputDlgData inputdlg[2];

View File

@ -87,9 +87,13 @@ ConfigEntry PlatformConfigFile[] =
{"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], 0x0E, NULL, 0},
{"HKKey_Mic", 0, &HKKeyMapping[HK_Mic], 0x35, NULL, 0},
{"HKKey_FastForward", 0, &HKKeyMapping[HK_FastForward], 0x0F, NULL, 0},
{"HKKey_FastForwardToggle", 0, &HKKeyMapping[HK_FastForwardToggle], -1, NULL, 0}, // TODO: This doesn't unbind the key, just sets it to some random key
{"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1, NULL, 0},
{"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1, NULL, 0},
{"HKJoy_FastForward", 0, &HKJoyMapping[HK_FastForward], -1, NULL, 0},
{"HKJoy_FastForwardToggle", 0, &HKJoyMapping[HK_FastForwardToggle], -1, NULL, 0},
{"WindowWidth", 0, &WindowWidth, 256, NULL, 0},
{"WindowHeight", 0, &WindowHeight, 384, NULL, 0},

View File

@ -25,7 +25,8 @@ enum
{
HK_Lid = 0,
HK_Mic,
HK_FastForward,
HK_FastForwardToggle,
HK_MAX
};

View File

@ -81,6 +81,8 @@ uiMenuItem* MenuItem_ScreenGap[6];
uiMenuItem* MenuItem_ScreenLayout[3];
uiMenuItem* MenuItem_ScreenSizing[4];
uiMenuItem* MenuItem_LimitFPS;
SDL_Thread* EmuThread;
int EmuRunning;
volatile int EmuStatus;
@ -127,6 +129,7 @@ s16* MicWavBuffer;
u32 MicCommand;
bool HotkeyFPSToggle = false;
void SetupScreenRects(int width, int height);
@ -497,6 +500,27 @@ int EmuThreadFunc(void* burp)
HotkeyMask |= 0x1;
}
if (JoyButtonPressed(Config::HKJoyMapping[HK_FastForwardToggle], njoybuttons, joybuttons, joyhat))
{
HotkeyFPSToggle = !HotkeyFPSToggle;
Config::LimitFPS = !Config::LimitFPS;
uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
}
if (!HotkeyFPSToggle) // For fast forward (hold) hotkey
{
if (JoyButtonHeld(Config::HKJoyMapping[HK_FastForward], njoybuttons, joybuttons, joyhat))
{
Config::LimitFPS = false;
uiMenuItemSetChecked(MenuItem_LimitFPS, false);
}
else if (!Config::LimitFPS)
{
Config::LimitFPS = true;
uiMenuItemSetChecked(MenuItem_LimitFPS, true);
}
}
if (JoyButtonHeld(Config::HKJoyMapping[HK_Mic], njoybuttons, joybuttons, joyhat))
MicCommand |= 2;
else
@ -745,6 +769,19 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
if (evt->Scancode == Config::HKKeyMapping[HK_Mic])
MicCommand &= ~1;
if (evt->Scancode == Config::HKKeyMapping[HK_FastForwardToggle])
{
HotkeyFPSToggle = !HotkeyFPSToggle;
Config::LimitFPS = !Config::LimitFPS;
uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
}
if (evt->Scancode == Config::HKKeyMapping[HK_FastForward] && !HotkeyFPSToggle)
{
Config::LimitFPS = true;
uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
}
}
else if (!evt->Repeat)
{
@ -776,6 +813,12 @@ int OnAreaKeyEvent(uiAreaHandler* handler, uiArea* area, uiAreaKeyEvent* evt)
if (evt->Scancode == Config::HKKeyMapping[HK_Mic])
MicCommand |= 1;
if (evt->Scancode == Config::HKKeyMapping[HK_FastForward] && !HotkeyFPSToggle)
{
Config::LimitFPS = false;
uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
}
if (evt->Scancode == 0x57) // F11
NDS::debug(0);
}
@ -1932,9 +1975,9 @@ int main(int argc, char** argv)
uiMenuItemOnClicked(menuitem, OnSetScreenFiltering, NULL);
uiMenuItemSetChecked(menuitem, Config::ScreenFilter==1);
menuitem = uiMenuAppendCheckItem(menu, "Limit framerate");
uiMenuItemOnClicked(menuitem, OnSetLimitFPS, NULL);
uiMenuItemSetChecked(menuitem, Config::LimitFPS==1);
MenuItem_LimitFPS = uiMenuAppendCheckItem(menu, "Limit framerate");
uiMenuItemOnClicked(MenuItem_LimitFPS, OnSetLimitFPS, NULL);
uiMenuItemSetChecked(MenuItem_LimitFPS, Config::LimitFPS==1);
int w = Config::WindowWidth;