XDarwin: Fixes to quartzKeyboard.c to prevent a crash using certain non-US keyboards
This commit is contained in:
parent
374bd88d10
commit
742d5d6adc
|
@ -4,7 +4,7 @@
|
||||||
Code to build a keymap using the Carbon Keyboard Layout API,
|
Code to build a keymap using the Carbon Keyboard Layout API,
|
||||||
which is supported on Mac OS X 10.2 and newer.
|
which is supported on Mac OS X 10.2 and newer.
|
||||||
|
|
||||||
Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
|
Copyright (c) 2003, 2007 Apple Inc.
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
Permission is hereby granted, free of charge, to any person
|
||||||
obtaining a copy of this software and associated documentation files
|
obtaining a copy of this software and associated documentation files
|
||||||
|
@ -214,35 +214,45 @@ Bool
|
||||||
DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
|
DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
|
||||||
{
|
{
|
||||||
KeyboardLayoutRef key_layout;
|
KeyboardLayoutRef key_layout;
|
||||||
const void *chr_data;
|
const void *chr_data = NULL;
|
||||||
int num_keycodes = NUM_KEYCODES;
|
int num_keycodes = NUM_KEYCODES;
|
||||||
UInt32 keyboard_type = 0;
|
UInt32 keyboard_type = 0;
|
||||||
int is_uchr, i, j;
|
int is_uchr, i, j;
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
KeySym *k;
|
KeySym *k;
|
||||||
|
|
||||||
KLGetCurrentKeyboardLayout (&key_layout);
|
TISInputSourceRef currentKeyLayoutRef = TISCopyCurrentKeyboardLayoutInputSource();
|
||||||
KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
|
if (currentKeyLayoutRef)
|
||||||
|
{
|
||||||
|
CFDataRef currentKeyLayoutDataRef = (CFDataRef )TISGetInputSourceProperty(currentKeyLayoutRef, kTISPropertyUnicodeKeyLayoutData);
|
||||||
|
if (currentKeyLayoutDataRef)
|
||||||
|
chr_data = CFDataGetBytePtr(currentKeyLayoutDataRef);
|
||||||
|
}
|
||||||
|
|
||||||
if (chr_data != NULL)
|
if (chr_data != NULL)
|
||||||
{
|
{
|
||||||
is_uchr = 1;
|
KLGetCurrentKeyboardLayout (&key_layout);
|
||||||
keyboard_type = LMGetKbdType ();
|
KLGetKeyboardLayoutProperty (key_layout, kKLuchrData, &chr_data);
|
||||||
|
|
||||||
|
if (chr_data != NULL)
|
||||||
|
{
|
||||||
|
is_uchr = 1;
|
||||||
|
keyboard_type = LMGetKbdType ();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
|
||||||
|
|
||||||
|
if (chr_data == NULL)
|
||||||
|
{
|
||||||
|
ErrorF ( "Couldn't get uchr or kchr resource\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
is_uchr = 0;
|
||||||
|
num_keycodes = 128;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
KLGetKeyboardLayoutProperty (key_layout, kKLKCHRData, &chr_data);
|
|
||||||
|
|
||||||
if (chr_data == NULL)
|
|
||||||
{
|
|
||||||
ErrorF ( "Couldn't get uchr or kchr resource\n");
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
is_uchr = 0;
|
|
||||||
num_keycodes = 128;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* Scan the keycode range for the Unicode character that each
|
/* Scan the keycode range for the Unicode character that each
|
||||||
key produces in the four shift states. Then convert that to
|
key produces in the four shift states. Then convert that to
|
||||||
|
@ -367,6 +377,8 @@ DarwinModeReadSystemKeymap (darwinKeyboardInfo *info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(currentKeyLayoutRef) CFRelease(currentKeyLayoutRef);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user