Merge pull request #401 from Ace4896/fast-forward-hotkey

Add Fast Forward (Hold and Toggle) Hotkeys
This commit is contained in:
Arisotura 2019-06-04 15:53:32 +02:00 committed by GitHub
commit 33caccf701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 7 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

@ -88,11 +88,15 @@ ConfigEntry PlatformConfigFile[] =
{"Joy_X", 0, &JoyMapping[10], -1, NULL, 0},
{"Joy_Y", 0, &JoyMapping[11], -1, NULL, 0},
{"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], 0x0D, NULL, 0},
{"HKKey_Mic", 0, &HKKeyMapping[HK_Mic], 0x35, NULL, 0},
{"HKKey_Lid", 0, &HKKeyMapping[HK_Lid], 0x0D, 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},
{"HKJoy_Lid", 0, &HKJoyMapping[HK_Lid], -1, NULL, 0},
{"HKJoy_Mic", 0, &HKJoyMapping[HK_Mic], -1, NULL, 0},
{"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

@ -159,6 +159,7 @@ s16* MicWavBuffer;
u32 MicCommand;
bool HotkeyFPSToggle = false;
void SetupScreenRects(int width, int height);
@ -838,6 +839,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
@ -1126,6 +1148,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)
{
@ -1157,6 +1192,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
OSD::AddMessage(0x00FFFF, "OSD test");
//NDS::debug(0);
@ -2079,6 +2120,7 @@ void OnSetLimitFPS(uiMenuItem* item, uiWindow* window, void* blarg)
int chk = uiMenuItemChecked(item);
if (chk != 0) Config::LimitFPS = true;
else Config::LimitFPS = false;
HotkeyFPSToggle = !Config::LimitFPS; // ensure that the hotkey toggle indicator is synced with this menu item
}
void ApplyNewSettings(int type)
@ -2307,6 +2349,7 @@ void CreateMainWindowMenu()
uiMenuAppendSubmenu(menu, submenu);
}
MenuItem_ScreenFilter = uiMenuAppendCheckItem(menu, "Screen filtering");
uiMenuItemOnClicked(MenuItem_ScreenFilter, OnSetScreenFiltering, NULL);