Mercurial > sdl-ios-xcode
changeset 1686:8d7fecceb9ef SDL-1.3
Added the unicode keysym memory again for backwards compatibility.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 18 Jun 2006 13:47:19 +0000 |
parents | 66267c6a0b12 |
children | d36048e8e302 |
files | include/SDL_events.h include/SDL_keyboard.h src/SDL_compat.c test/testwm.c |
diffstat | 4 files changed, 38 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/include/SDL_events.h Sun Jun 18 07:31:45 2006 +0000 +++ b/include/SDL_events.h Sun Jun 18 13:47:19 2006 +0000 @@ -129,7 +129,7 @@ /** * \struct SDL_KeyboardEvent * - * \brief Keyboard event structure + * \brief Keyboard button event structure */ typedef struct SDL_KeyboardEvent { @@ -141,6 +141,19 @@ } SDL_KeyboardEvent; /** + * \struct SDL_CharEvent + * + * \brief Keyboard input event structure + */ +typedef struct SDL_CharEvent +{ + Uint8 type; /**< SDL_CHARINPUT (FIXME: NYI) */ + Uint8 which; /**< The keyboard device index */ + char text[32]; /**< The input text */ + SDL_WindowID windowID; /**< The window with keyboard focus, if any */ +} SDL_CharEvent; + +/** * \struct SDL_MouseMotionEvent * * \brief Mouse motion event structure @@ -364,7 +377,7 @@ The filter is protypted as: */ -typedef int (SDLCALL * SDL_EventFilter) (const SDL_Event * event); +typedef int (SDLCALL * SDL_EventFilter) (SDL_Event * event); /* If the filter returns 1, then the event will be added to the internal queue. If it returns 0, then the event will be dropped from the queue, but the
--- a/include/SDL_keyboard.h Sun Jun 18 07:31:45 2006 +0000 +++ b/include/SDL_keyboard.h Sun Jun 18 13:47:19 2006 +0000 @@ -52,6 +52,7 @@ Uint8 padding[3]; /**< alignment padding */ Uint16 sym; /**< SDL virtual keysym */ Uint16 mod; /**< current key modifiers */ + Uint32 unicode; /**< OBSOLETE, use SDL_CharEvent instead */ } SDL_keysym; /* Function prototypes */
--- a/src/SDL_compat.c Sun Jun 18 07:31:45 2006 +0000 +++ b/src/SDL_compat.c Sun Jun 18 13:47:19 2006 +0000 @@ -150,10 +150,10 @@ return modes; } -static int (*orig_eventfilter) (const SDL_Event * event); +static int (*orig_eventfilter) (SDL_Event * event); static int -SDL_CompatEventFilter(const SDL_Event * event) +SDL_CompatEventFilter(SDL_Event * event) { SDL_Event fake; @@ -203,6 +203,24 @@ SDL_PushEvent(&fake); break; } + case SDL_KEYDOWN: + case SDL_KEYUP: + { + Uint32 unicode = 0; + if (event->key.type == SDL_KEYDOWN && event->key.keysym.sym < 256) { + int shifted = !!(event->key.keysym.mod & KMOD_SHIFT); + int capslock = !!(event->key.keysym.mod & KMOD_CAPS); + if ((shifted ^ capslock) != 0) { + unicode = SDL_toupper(event->key.keysym.sym); + } else { + unicode = event->key.keysym.sym; + } + } + if (unicode) { + event->key.keysym.unicode = unicode; + } + break; + } } if (orig_eventfilter) { return orig_eventfilter(event); @@ -228,7 +246,7 @@ SDL_Surface * SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { - int (*filter) (const SDL_Event * event); + int (*filter) (SDL_Event * event); const SDL_DisplayMode *desktop_mode; SDL_DisplayMode mode; int i;