Date: Sat, 14 Dec 2002 13:33:05 -0500

From: Darrell Walisser
Subject: Re: crash in SDL / OSX

> Yes, compose keys and other "dead" keys should have unicode 0.
> As a hack, if you get multiple composed characters, you can send the
> sequence with a valid unicode and a keysym of 0.  It's because of
> things like this that I'm separating the key and char events in SDL 2.0

I've done this and here's the patch.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40562
This commit is contained in:
Sam Lantinga 2002-12-15 09:09:31 +00:00
parent e2cbed54eb
commit 8e0540e5cf
2 changed files with 38 additions and 11 deletions

View file

@ -206,26 +206,52 @@ static void QZ_InitOSKeymap (_THIS) {
static void QZ_DoKey (_THIS, int state, NSEvent *event) { static void QZ_DoKey (_THIS, int state, NSEvent *event) {
NSString *chars; NSString *chars;
int i; unsigned int numChars;
SDL_keysym key; SDL_keysym key;
/* /*
An event can contain multiple characters A key event can contain multiple characters,
I'll ignore this fact for now, since there or no characters at all. In most cases, it
is only one virtual key code per event, so will contain a single character. If it contains
no good way to handle this. 0 characters, we'll use 0 as the unicode. If it
contains multiple characters, we'll use 0 as
the scancode/keysym.
*/ */
chars = [ event characters ]; chars = [ event characters ];
for (i =0; i < 1 /*[ chars length ] */; i++) { numChars = [ chars length ];
if (numChars == 1) {
key.scancode = [ event keyCode ]; key.scancode = [ event keyCode ];
key.sym = keymap [ key.scancode ]; key.sym = keymap [ key.scancode ];
key.unicode = [ chars characterAtIndex:0 ];
key.mod = KMOD_NONE;
SDL_PrivateKeyboard (state, &key);
}
else if (numChars == 0) {
key.scancode = [ event keyCode ];
key.sym = keymap [ key.scancode ];
key.unicode = 0;
key.mod = KMOD_NONE;
SDL_PrivateKeyboard (state, &key);
}
else /* (numChars > 1) */ {
int i;
for (i = 0; i < numChars; i++) {
key.scancode = 0;
key.sym = 0;
key.unicode = [ chars characterAtIndex:i]; key.unicode = [ chars characterAtIndex:i];
key.mod = KMOD_NONE; key.mod = KMOD_NONE;
SDL_PrivateKeyboard (state, &key); SDL_PrivateKeyboard (state, &key);
} }
} }
}
static void QZ_DoModifiers (_THIS, unsigned int newMods) { static void QZ_DoModifiers (_THIS, unsigned int newMods) {

View file

@ -52,6 +52,7 @@
#include <OpenGL/OpenGL.h> #include <OpenGL/OpenGL.h>
#include <Carbon/Carbon.h> #include <Carbon/Carbon.h>
#include <QuickTime/QuickTime.h> #include <QuickTime/QuickTime.h>
#include <IOKit/IOKitLib.h> /* For powersave handling */
#include "SDL_video.h" #include "SDL_video.h"
#include "SDL_error.h" #include "SDL_error.h"