mirror of
https://github.com/optiscaler/OptiScaler.git
synced 2026-05-03 16:21:46 +00:00
Allow for unbinding keybinds from the menu (#522)
* Allow for unbinding the key from the menu * Formatting
This commit is contained in:
committed by
GitHub
parent
4ce13e3b2f
commit
eed4c2bf1d
@@ -427,6 +427,7 @@ Scale=auto
|
||||
; For all keycode values you can check this address
|
||||
; https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
||||
; Integer value - Default (auto) is 0x2D -> VK_INSERT, previous default key VK_HOME is 0x24
|
||||
; -1 -> No shortcut key
|
||||
ShortcutKey=auto
|
||||
|
||||
; Extends scaling ratio limits to 0.1 - 6.0
|
||||
@@ -465,10 +466,12 @@ FpsOverlayType=auto
|
||||
|
||||
; Shortcut key for fps overlay
|
||||
; Integer value - Default (auto) is 0x21 -> VK_PRIOR
|
||||
; -1 -> No shortcut key
|
||||
FpsShortcutKey=auto
|
||||
|
||||
; Shortcut key for fps overlay type cycle
|
||||
; Integer value - Default (auto) is 0x22 -> VK_NEXT
|
||||
; -1 -> No shortcut key
|
||||
FpsCycleShortcutKey=auto
|
||||
|
||||
; Enables Horizontal Fps overlay layout
|
||||
|
||||
+12
-3
@@ -754,14 +754,23 @@ bool Config::SaveIni()
|
||||
{
|
||||
ini.SetValue("Menu", "Scale", GetFloatValue(Instance()->MenuScale.value_for_config()).c_str());
|
||||
ini.SetValue("Menu", "OverlayMenu", GetBoolValue(Instance()->OverlayMenu.value_for_config()).c_str());
|
||||
ini.SetValue("Menu", "ShortcutKey", GetIntValue(Instance()->ShortcutKey.value_for_config(), true).c_str());
|
||||
|
||||
auto setting = Instance()->ShortcutKey.value_for_config();
|
||||
ini.SetValue("Menu", "ShortcutKey",
|
||||
GetIntValue(Instance()->ShortcutKey.value_for_config(), setting > 0).c_str());
|
||||
|
||||
ini.SetValue("Menu", "ExtendedLimits", GetBoolValue(Instance()->ExtendedLimits.value_for_config()).c_str());
|
||||
ini.SetValue("Menu", "ShowFps", GetBoolValue(Instance()->ShowFps.value_for_config()).c_str());
|
||||
ini.SetValue("Menu", "UseHQFont", GetBoolValue(Instance()->UseHQFont.value_for_config()).c_str());
|
||||
|
||||
setting = Instance()->FpsShortcutKey.value_for_config();
|
||||
ini.SetValue("Menu", "FpsShortcutKey",
|
||||
GetIntValue(Instance()->FpsShortcutKey.value_for_config(), true).c_str());
|
||||
GetIntValue(Instance()->FpsShortcutKey.value_for_config(), setting > 0).c_str());
|
||||
|
||||
setting = Instance()->FpsCycleShortcutKey.value_for_config();
|
||||
ini.SetValue("Menu", "FpsCycleShortcutKey",
|
||||
GetIntValue(Instance()->FpsCycleShortcutKey.value_for_config(), true).c_str());
|
||||
GetIntValue(Instance()->FpsCycleShortcutKey.value_for_config(), setting > 0).c_str());
|
||||
|
||||
ini.SetValue("Menu", "FpsOverlayPos", GetIntValue(Instance()->FpsOverlayPos.value_for_config()).c_str());
|
||||
ini.SetValue("Menu", "FpsOverlayType", GetIntValue(Instance()->FpsOverlayType.value_for_config()).c_str());
|
||||
ini.SetValue("Menu", "FpsOverlayHorizontal",
|
||||
|
||||
@@ -144,6 +144,8 @@ template <class T, HasDefaultValue defaultState = WithDefault> class CustomOptio
|
||||
}
|
||||
};
|
||||
|
||||
constexpr int UnboundKey = -1;
|
||||
|
||||
class Config
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -461,7 +461,7 @@ ImGuiKey MenuCommon::ImGui_ImplWin32_VirtualKeyToImGuiKey(WPARAM wParam)
|
||||
}
|
||||
}
|
||||
|
||||
static USHORT lastKey = 0;
|
||||
static int lastKey = 0;
|
||||
|
||||
class Keybind
|
||||
{
|
||||
@@ -469,8 +469,11 @@ class Keybind
|
||||
int id;
|
||||
bool waitingForKey = false;
|
||||
|
||||
std::string KeyNameFromVirtualKeyCode(UINT virtualKey)
|
||||
std::string KeyNameFromVirtualKeyCode(USHORT virtualKey)
|
||||
{
|
||||
if (virtualKey == (USHORT) UnboundKey)
|
||||
return "Unbound";
|
||||
|
||||
UINT scanCode = MapVirtualKeyW(virtualKey, MAPVK_VK_TO_VSC);
|
||||
|
||||
// Keys like Home would display as Num 0 without this fix
|
||||
@@ -526,12 +529,15 @@ class Keybind
|
||||
if (lastKey == 0 || lastKey == VK_LBUTTON || lastKey == VK_RBUTTON || lastKey == VK_MBUTTON)
|
||||
return;
|
||||
|
||||
if (lastKey == VK_ESCAPE || lastKey == VK_BACK)
|
||||
if (lastKey == VK_ESCAPE)
|
||||
{
|
||||
waitingForKey = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastKey == VK_BACK)
|
||||
lastKey = UnboundKey;
|
||||
|
||||
configKey = lastKey;
|
||||
waitingForKey = false;
|
||||
return;
|
||||
@@ -3858,6 +3864,7 @@ bool MenuCommon::RenderMenu()
|
||||
|
||||
ImGui::Spacing();
|
||||
ImGui::Text("Key combinations are currently NOT supported!");
|
||||
ImGui::Text("Escape to cancel, Backspace to unbind");
|
||||
ImGui::Spacing();
|
||||
|
||||
static auto menu = Keybind("Menu", 10);
|
||||
|
||||
Reference in New Issue
Block a user