Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Added the unicode keysym memory again for backwards compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 18, 2006
1 parent 7e42c4a commit bcd3c30
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
17 changes: 15 additions & 2 deletions include/SDL_events.h
Expand Up @@ -129,7 +129,7 @@ typedef struct SDL_WindowEvent
/**
* \struct SDL_KeyboardEvent
*
* \brief Keyboard event structure
* \brief Keyboard button event structure
*/
typedef struct SDL_KeyboardEvent
{
Expand All @@ -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
*
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/SDL_keyboard.h
Expand Up @@ -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 */
Expand Down
24 changes: 21 additions & 3 deletions src/SDL_compat.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/testwm.c
Expand Up @@ -176,7 +176,7 @@ HotKey_Quit(void)
}

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

Expand Down

0 comments on commit bcd3c30

Please sign in to comment.