mirror of
https://github.com/yawut/SDL.git
synced 2026-10-01 20:56:44 -05:00
Added key composition support, courtesy of Kuon
--HG-- branch : SDL-1.2
This commit is contained in:
@@ -254,7 +254,7 @@ void QZ_InitOSKeymap (_THIS) {
|
||||
static void QZ_DoKey (_THIS, int state, NSEvent *event) {
|
||||
|
||||
NSString *chars;
|
||||
unsigned int numChars;
|
||||
unsigned int i, numChars;
|
||||
SDL_keysym key;
|
||||
|
||||
/*
|
||||
@@ -265,7 +265,8 @@ static void QZ_DoKey (_THIS, int state, NSEvent *event) {
|
||||
contains multiple characters, we'll use 0 as
|
||||
the scancode/keysym.
|
||||
*/
|
||||
if (SDL_TranslateUNICODE) {
|
||||
if (SDL_TranslateUNICODE && state == SDL_PRESSED) {
|
||||
[field_edit interpretKeyEvents:[NSArray arrayWithObject:event]];
|
||||
chars = [ event characters ];
|
||||
numChars = [ chars length ];
|
||||
} else {
|
||||
@@ -281,7 +282,7 @@ static void QZ_DoKey (_THIS, int state, NSEvent *event) {
|
||||
|
||||
SDL_PrivateKeyboard (state, &key);
|
||||
}
|
||||
else if (numChars == 1) {
|
||||
else if (numChars >= 1) {
|
||||
|
||||
key.scancode = [ event keyCode ];
|
||||
key.sym = keymap [ key.scancode ];
|
||||
@@ -289,11 +290,8 @@ static void QZ_DoKey (_THIS, int state, NSEvent *event) {
|
||||
key.mod = KMOD_NONE;
|
||||
|
||||
SDL_PrivateKeyboard (state, &key);
|
||||
}
|
||||
else /* (numChars > 1) */ {
|
||||
|
||||
int i;
|
||||
for (i = 0; i < numChars; i++) {
|
||||
for (i = 1; i < numChars; i++) {
|
||||
|
||||
key.scancode = 0;
|
||||
key.sym = 0;
|
||||
|
||||
@@ -99,6 +99,7 @@ typedef struct SDL_PrivateVideoData {
|
||||
SDL_Rect **client_mode_list; /* resolution list to pass back to client */
|
||||
SDLKey keymap[256]; /* Mac OS X to SDL key mapping */
|
||||
Uint32 current_mods; /* current keyboard modifiers, to track modifier state */
|
||||
NSText *field_edit; /* a field editor for keyboard composition processing */
|
||||
Uint32 last_virtual_button;/* last virtual mouse button pressed */
|
||||
io_connect_t power_connection; /* used with IOKit to detect wake from sleep */
|
||||
Uint8 expect_mouse_up; /* used to determine when to send mouse up events */
|
||||
@@ -146,6 +147,7 @@ typedef struct SDL_PrivateVideoData {
|
||||
#define client_mode_list (this->hidden->client_mode_list)
|
||||
#define keymap (this->hidden->keymap)
|
||||
#define current_mods (this->hidden->current_mods)
|
||||
#define field_edit (this->hidden->field_edit)
|
||||
#define last_virtual_button (this->hidden->last_virtual_button)
|
||||
#define power_connection (this->hidden->power_connection)
|
||||
#define expect_mouse_up (this->hidden->expect_mouse_up)
|
||||
|
||||
@@ -169,6 +169,7 @@ static void QZ_DeleteDevice (SDL_VideoDevice *device) {
|
||||
|
||||
static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
|
||||
|
||||
NSRect r = NSMakeRect(0.0, 0.0, 0.0, 0.0);
|
||||
const char *env = NULL;
|
||||
|
||||
/* Initialize the video settings; this data persists between mode switches */
|
||||
@@ -202,6 +203,7 @@ static int QZ_VideoInit (_THIS, SDL_PixelFormat *video_format) {
|
||||
cursor_should_be_visible = YES;
|
||||
cursor_visible = YES;
|
||||
current_mods = 0;
|
||||
field_edit = [[NSTextView alloc] initWithFrame:r];
|
||||
|
||||
if ( Gestalt(gestaltSystemVersion, &system_version) != noErr )
|
||||
system_version = 0;
|
||||
@@ -1456,6 +1458,11 @@ static void QZ_VideoQuit (_THIS) {
|
||||
opengl_library = NULL;
|
||||
}
|
||||
this->gl_config.driver_loaded = 0;
|
||||
|
||||
if (field_edit) {
|
||||
[field_edit release];
|
||||
field_edit = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0 /* Not used (apparently, it's really slow) */
|
||||
|
||||
Reference in New Issue
Block a user