Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added the unicode keysym memory again for backwards compatibility.

  • Loading branch information
slouken committed Jun 18, 2006
1 parent 7e42c4a commit bcd3c305b6017b1b133430e268cf7666940ad16b
Showing with 38 additions and 6 deletions.
  1. +15 −2 include/SDL_events.h
  2. +1 −0 include/SDL_keyboard.h
  3. +21 −3 src/SDL_compat.c
  4. +1 −1 test/testwm.c
@@ -129,7 +129,7 @@ typedef struct SDL_WindowEvent
/**
* \struct SDL_KeyboardEvent
*
* \brief Keyboard event structure
* \brief Keyboard button event structure
*/
typedef struct SDL_KeyboardEvent
{
@@ -140,6 +140,19 @@ typedef struct SDL_KeyboardEvent
SDL_WindowID windowID; /**< The window with keyboard focus, if any */
} 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
*
@@ -364,7 +377,7 @@ extern DECLSPEC int SDLCALL SDL_PushEvent(SDL_Event * event);
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
@@ -52,6 +52,7 @@ typedef struct SDL_keysym
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 */
@@ -150,10 +150,10 @@ SDL_ListModes(SDL_PixelFormat * format, Uint32 flags)
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_CompatEventFilter(const SDL_Event * event)
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_VideoPaletteChanged(void *userdata, SDL_Palette * palette)
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;
@@ -176,7 +176,7 @@ HotKey_Quit(void)
}

int SDLCALL
FilterEvents(const SDL_Event * event)
FilterEvents(SDL_Event * event)
{
static int reallyquit = 0;

0 comments on commit bcd3c30

Please sign in to comment.