Skip to content

Commit

Permalink
Merge pull request #2416 from exkrexpexfex/master
Browse files Browse the repository at this point in the history
NumLock emulation with Clear button on Apple full size keyboard
  • Loading branch information
elfmz authored Oct 6, 2024
2 parents 2d27844 + 18b72b8 commit b67cb1b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
13 changes: 13 additions & 0 deletions WinPort/src/Backend/WX/wxWinTranslations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,9 @@ bool KeyTracker::RightControl() const
//////////////////////

static DWORD s_cached_led_state = 0;
#ifdef __WXOSX__
static bool s_toggle_numlock = false;
#endif

#if defined (__WXGTK__) && defined (__HASX11__)
static int X11KeyCodeLookupUncached(wxUint32 keyflags)
Expand Down Expand Up @@ -594,6 +597,11 @@ wx2INPUT_RECORD::wx2INPUT_RECORD(BOOL KeyDown, const wxKeyEvent& event, const Ke
Event.KeyEvent.dwControlKeyState|= ENHANCED_KEY;
}

#ifdef __WXOSX__
if (Event.KeyEvent.wVirtualKeyCode == VK_CLEAR && KeyDown)
s_toggle_numlock = !s_toggle_numlock;
#endif

if (KeyDown || WINPORT(GetTickCount)() - key_tracker.LastKeydownTicks() > 500) {
s_cached_led_state = WxKeyboardLedsState();
}
Expand Down Expand Up @@ -649,8 +657,13 @@ DWORD WxKeyboardLedsState()
// to use wxGetKeyState with unsupported key causes assert callback
// to be invoked several times on each key event thats not good.
// Avoid asserts all the time by 'caching' unsupported state.
#ifdef __WXOSX__
// NumLock emulation with Clear button
if (s_toggle_numlock) {
#else
s_wx_assert_cache_bit = 1;
if ((s_wx_assert_cached_bits & 1) == 0 && wxGetKeyState(WXK_NUMLOCK)) {
#endif
out|= NUMLOCK_ON;
}

Expand Down
3 changes: 3 additions & 0 deletions far2l/src/console/keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2232,7 +2232,10 @@ FarKey CalcKeyCode(INPUT_RECORD *rec, int RealKey, int *NotMacros)
return '9';

return Modif | (Opt.UseNumPad ? KEY_NUMPAD9 : KEY_PGUP);
#ifndef __APPLE__
// Clear button is used as NumLock emulator on OSX
case VK_CLEAR:
#endif
case VK_NUMPAD5:

if (CtrlState & ENHANCED_KEY) {
Expand Down

0 comments on commit b67cb1b

Please sign in to comment.