@@ -270,9 +270,7 @@ void _al_osx_keyboard_handler(int pressed, NSEvent *event, ALLEGRO_DISPLAY* dpy)
270
270
if (pressed) {
271
271
int32_t unichar = 0 ;
272
272
bool new_input = _al_get_keyboard_compat_version () >= AL_ID (5 , 2 , 10 , 0 );
273
- NSString *raw_characters = [event charactersIgnoringModifiers ];
274
273
NSString *characters = [event characters ];
275
- UniChar raw_character = ([raw_characters length ] > 0 ) ? [raw_characters characterAtIndex: 0 ] : 0 ;
276
274
UniChar character = ([characters length ] > 0 ) ? [characters characterAtIndex: 0 ] : 0 ;
277
275
278
276
if (new_input) {
@@ -307,9 +305,10 @@ void _al_osx_keyboard_handler(int pressed, NSEvent *event, ALLEGRO_DISPLAY* dpy)
307
305
/* For some reason, pad enter sends a ^C. */
308
306
if (scancode == ALLEGRO_KEY_PAD_ENTER && unichar == 3 )
309
307
unichar = ' \r ' ;
310
- /* Single out the few printable characters under 32 */
311
- if (unichar < ' ' && (unichar != ' \r ' && unichar != ' \t ' && unichar != ' \b ' ))
312
- unichar = 0 ;
308
+ /* For some reason, Ctrl-<key> sends capital version of the character,
309
+ and not the correct invisible character. */
310
+ if (key_shifts & ALLEGRO_KEYMOD_CTRL)
311
+ unichar = character;
313
312
al_ustr_free (ustr);
314
313
}
315
314
CFRelease (keyboard_input);
@@ -320,14 +319,13 @@ void _al_osx_keyboard_handler(int pressed, NSEvent *event, ALLEGRO_DISPLAY* dpy)
320
319
/* Apple maps function, arrow, and other keys to Unicode points.
321
320
We want to generate CHAR events for them, so we'll override the translation logic.
322
321
_handle_key_press will set the unichar back to 0 for these keys. */
323
- if (character >= 0xF700 && character <= 0xF747 )
324
- unichar = -1 ;
325
- /* The delete key. */
326
- if (character == 0xF728 && new_input)
327
- unichar = 127 ;
328
- /* Special processing to send character 1 for CTRL-A, 2 for CTRL-B etc. */
329
- if ((key_shifts & ALLEGRO_KEYMOD_CTRL) && (isalpha (raw_character)))
330
- unichar = tolower (raw_character) - ' a' + 1 ;
322
+ if (character >= 0xF700 && character <= 0xF747 ) {
323
+ /* The old input did not handle this key (delete) correctly. We preserve the old behavior. */
324
+ if (new_input && character == 0xF728 )
325
+ unichar = 127 ;
326
+ else
327
+ unichar = -1 ;
328
+ }
331
329
bool is_repeat = pressed ? ([event isARepeat ] == YES ) : false ;
332
330
_handle_key_press (dpy, unichar , scancode, key_shifts, is_repeat);
333
331
}
0 commit comments