From 730e291da86d3c8f671757d513ef57577af08e5a Mon Sep 17 00:00:00 2001 From: Pavel Sountsov Date: Sat, 30 Nov 2024 12:27:10 -0800 Subject: [PATCH] Try to fix Ctrl-key chords on MacOS with the new input. The old code had a confusing logic that dealt with Ctrl-keys, which was misinterpreted by me, which I now changed. Separately, the new input had logic to filter out characters under 32, which was not necessary. --- src/macosx/keybd.m | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/macosx/keybd.m b/src/macosx/keybd.m index 11e05e19f..0cbb0fa40 100644 --- a/src/macosx/keybd.m +++ b/src/macosx/keybd.m @@ -269,10 +269,8 @@ void _al_osx_keyboard_handler(int pressed, NSEvent *event, ALLEGRO_DISPLAY* dpy) if (pressed) { int32_t unichar = 0; - bool new_input = _al_get_keyboard_compat_version() >= AL_ID(5, 2, 10, 0); - NSString *raw_characters = [event charactersIgnoringModifiers]; + bool new_input = false;//_al_get_keyboard_compat_version() >= AL_ID(5, 2, 10, 0); NSString *characters = [event characters]; - UniChar raw_character = ([raw_characters length] > 0) ? [raw_characters characterAtIndex: 0] : 0; UniChar character = ([characters length] > 0) ? [characters characterAtIndex: 0] : 0; if (new_input) { @@ -307,9 +305,6 @@ void _al_osx_keyboard_handler(int pressed, NSEvent *event, ALLEGRO_DISPLAY* dpy) /* For some reason, pad enter sends a ^C. */ if (scancode == ALLEGRO_KEY_PAD_ENTER && unichar == 3) unichar = '\r'; - /* Single out the few printable characters under 32 */ - if (unichar < ' ' && (unichar != '\r' && unichar != '\t' && unichar != '\b')) - unichar = 0; al_ustr_free(ustr); } CFRelease(keyboard_input); @@ -326,8 +321,8 @@ void _al_osx_keyboard_handler(int pressed, NSEvent *event, ALLEGRO_DISPLAY* dpy) if (character == 0xF728 && new_input) unichar = 127; /* Special processing to send character 1 for CTRL-A, 2 for CTRL-B etc. */ - if ((key_shifts & ALLEGRO_KEYMOD_CTRL) && (isalpha(raw_character))) - unichar = tolower(raw_character) - 'a' + 1; + if (key_shifts & ALLEGRO_KEYMOD_CTRL) + unichar = character; bool is_repeat = pressed ? ([event isARepeat] == YES) : false; _handle_key_press(dpy, unichar, scancode, key_shifts, is_repeat); }