Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom keybinds #724

Open
wants to merge 30 commits into
base: dev
Choose a base branch
from

Conversation

ToeKneeRED
Copy link
Contributor

@ToeKneeRED ToeKneeRED commented Oct 16, 2024

Relies on tiltedphoques/TiltedHooks#7

NOTES:

  • This could use additional testing, especially with keyboard layouts besides standard US
    • To test:
      • STR UI also has to be rebuilt for this PR
      • Should be able to set keys via config with the below names (or single-character key name, ex. $), or use the Keybinds window in the Debug UI
      • Should be able to cancel rebinding by pressing Escape
      • Should not be able to bind both to the same key
      • Should support wide characters
      • Keybinds should not work while any text input field (chat, server address, and server password fields) are focused
  • Does not support mouse buttons
  • Currently only supports a single key for each bind
  • Key defaults:
    • STR UI: F2
    • Debug UI: F3
    • Reveal Players: F4
  • [Internal] section of config should not be messed with
  • [Keybinds] section of config is where key names would be input
  • I will add a list of currently known-acceptable key names on the wiki that can be used (as far as I know) in the config beforehand so players can set the keybind via the config without having to open the rebind menu

List of known acceptable key names (should accept any single-character key based on keyboard layout as well): Backspace, Tab, Enter, LSHIFT, RSHIFT, LCTRL, RCTRL, LALT, RALT, Pause, Caps Lock, IME Kana mode, IME Kanji mode, Esc, IME convert, IME nonconvert, Space, Page Up, Page Down, End, Home, Arrow Left, Arrow Up, Arrow Right, Arrow Down, Ins, Del, LWIN, RWIN, Applications, Sleep, NUMPAD 0, NUMPAD 1, NUMPAD 2, NUMPAD 3, NUMPAD 4, NUMPAD 5, NUMPAD 6, NUMPAD 7, NUMPAD 8, NUMPAD 9, NUMPAD *, NUMPAD +, NUMPAD -, NUMPAD ., NUMPAD /, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, Num Lock, ScrLk, Browser Back, Browser Forward, Browser Refresh, Browser Stop, Browser Search, Browser Favorites, Browser Home, Volume Mute, Volume Down, Volume Up, Next Track, Previous Track, Stop Media, Start Mail, Select Media

ex.
[Keybinds]
sUiKey=RCTRL
sDebugKey=]
sRevealPlayersKey=à


KeybindService

  • Creates/loads keybinds.ini config file, sets keys (for KeybindService, InputService, and DebugService)
    • If the user changes a keybind via the config file, the key will not be "confirmed" until it is pressed
    • If the user did not change the keybind via the config file, it will "confirm" the keybind
  • If a key is not confirmed, it checks if the correct keycodes are tied together by checking either VirtualKey via OnVirtualKeyPress or DirectInput via OnDirectInputKeyPress
    • Checks all aspects of a Key to see if they match (name, VirtualKey, or DirectInput)
  • Rebinding a key via its debug menu:
    • Press Escape to cancel rebinding
    • Press the new key to rebind either UI or Debug to:
      • BindKey
        • If the keycode equals the other keybind's keycode or its own, cancel the rebind (should not be able to rebind two things to the same key)
        • The key to be rebound is determined by the first parameter (a KeybindService::Keybind enum value)

InputService

  • Add Toggle to call all the necessary UI toggle code
  • Triggers new KeyPressEvent to send out VirtualKey as necessary
  • Add STR local UI key

DebugService

  • Add m_debugKeyPressed to manage m_showDebugStuff
  • Add KeybindView.cpp
  • Add Local debug UI key

MagicService

  • RevealKeybindPressed
  • m_revealKeybindPressed

@ToeKneeRED ToeKneeRED marked this pull request as draft October 25, 2024 02:04
@ToeKneeRED ToeKneeRED marked this pull request as ready for review November 27, 2024 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant