comparison src/video/cocoa/SDL_cocoakeyboard.m @ 2305:fbe8ff44c519

First pass of new SDL scancode concept for X11.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 07 Feb 2008 15:31:09 +0000
parents 50f58ce12497
children 99210400e8b9
comparison
equal deleted inserted replaced
2304:50f58ce12497 2305:fbe8ff44c519
20 slouken@libsdl.org 20 slouken@libsdl.org
21 */ 21 */
22 #include "SDL_config.h" 22 #include "SDL_config.h"
23 23
24 #include "SDL_cocoavideo.h" 24 #include "SDL_cocoavideo.h"
25 #include "SDL_cocoakeys.h"
26 25
27 #include "../../events/SDL_keyboard_c.h" 26 #include "../../events/SDL_keyboard_c.h"
27 #include "../../events/scancodes_darwin.h"
28 28
29 #include <Carbon/Carbon.h> 29 #include <Carbon/Carbon.h>
30 30
31 31
32 #ifndef NX_DEVICERCTLKEYMASK 32 #ifndef NX_DEVICERCTLKEYMASK
370 KLGetKeyboardLayoutProperty(key_layout, kKLuchrData, &chr_data); 370 KLGetKeyboardLayoutProperty(key_layout, kKLuchrData, &chr_data);
371 if (chr_data) { 371 if (chr_data) {
372 UInt32 keyboard_type = LMGetKbdType(); 372 UInt32 keyboard_type = LMGetKbdType();
373 OSStatus err; 373 OSStatus err;
374 374
375 for (i = 0; i < SDL_arraysize(scancode_table); i++) { 375 for (i = 0; i < SDL_arraysize(darwin_scancode_table); i++) {
376 UniChar s[8]; 376 UniChar s[8];
377 UniCharCount len; 377 UniCharCount len;
378 UInt32 dead_key_state; 378 UInt32 dead_key_state;
379 379
380 /* Make sure this scancode is a valid character scancode */ 380 /* Make sure this scancode is a valid character scancode */
381 scancode = scancode_table[i]; 381 scancode = darwin_scancode_table[i];
382 if (scancode == SDL_SCANCODE_UNKNOWN || 382 if (scancode == SDL_SCANCODE_UNKNOWN ||
383 (keymap[scancode] & SDLK_SCANCODE_MASK)) { 383 (keymap[scancode] & SDLK_SCANCODE_MASK)) {
384 continue; 384 continue;
385 } 385 }
386 386
405 if (chr_data) { 405 if (chr_data) {
406 for (i = 0; i < 128; i++) { 406 for (i = 0; i < 128; i++) {
407 UInt32 c, state = 0; 407 UInt32 c, state = 0;
408 408
409 /* Make sure this scancode is a valid character scancode */ 409 /* Make sure this scancode is a valid character scancode */
410 scancode = scancode_table[i]; 410 scancode = darwin_scancode_table[i];
411 if (scancode == SDL_SCANCODE_UNKNOWN || 411 if (scancode == SDL_SCANCODE_UNKNOWN ||
412 (keymap[scancode] & SDLK_SCANCODE_MASK)) { 412 (keymap[scancode] & SDLK_SCANCODE_MASK)) {
413 continue; 413 continue;
414 } 414 }
415 415
485 485
486 if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) { 486 if ((scancode == 10 || scancode == 50) && KBGetLayoutType(LMGetKbdType()) == kKeyboardISO) {
487 /* see comments in SDL_cocoakeys.h */ 487 /* see comments in SDL_cocoakeys.h */
488 scancode = 60 - scancode; 488 scancode = 60 - scancode;
489 } 489 }
490 if (scancode < SDL_arraysize(scancode_table)) { 490 if (scancode < SDL_arraysize(darwin_scancode_table)) {
491 code = scancode_table[scancode]; 491 code = darwin_scancode_table[scancode];
492 } 492 }
493 else { 493 else {
494 /* Hmm, does this ever happen? If so, need to extend the keymap... */ 494 /* Hmm, does this ever happen? If so, need to extend the keymap... */
495 code = SDL_SCANCODE_UNKNOWN; 495 code = SDL_SCANCODE_UNKNOWN;
496 } 496 }