Added the unicode keysym memory again for backwards compatibility. SDL-1.3
authorSam Lantinga <slouken@libsdl.org>
Sun, 18 Jun 2006 13:47:19 +0000
branchSDL-1.3
changeset 16868d7fecceb9ef
parent 1685 66267c6a0b12
child 1687 d36048e8e302
Added the unicode keysym memory again for backwards compatibility.
include/SDL_events.h
include/SDL_keyboard.h
src/SDL_compat.c
test/testwm.c
     1.1 --- a/include/SDL_events.h	Sun Jun 18 07:31:45 2006 +0000
     1.2 +++ b/include/SDL_events.h	Sun Jun 18 13:47:19 2006 +0000
     1.3 @@ -129,7 +129,7 @@
     1.4  /**
     1.5   * \struct SDL_KeyboardEvent
     1.6   *
     1.7 - * \brief Keyboard event structure
     1.8 + * \brief Keyboard button event structure
     1.9   */
    1.10  typedef struct SDL_KeyboardEvent
    1.11  {
    1.12 @@ -141,6 +141,19 @@
    1.13  } SDL_KeyboardEvent;
    1.14  
    1.15  /**
    1.16 + * \struct SDL_CharEvent
    1.17 + *
    1.18 + * \brief Keyboard input event structure
    1.19 + */
    1.20 +typedef struct SDL_CharEvent
    1.21 +{
    1.22 +    Uint8 type;             /**< SDL_CHARINPUT (FIXME: NYI) */
    1.23 +    Uint8 which;            /**< The keyboard device index */
    1.24 +    char text[32];          /**< The input text */
    1.25 +    SDL_WindowID windowID;  /**< The window with keyboard focus, if any */
    1.26 +} SDL_CharEvent;
    1.27 +
    1.28 +/**
    1.29   * \struct SDL_MouseMotionEvent
    1.30   *
    1.31   * \brief Mouse motion event structure
    1.32 @@ -364,7 +377,7 @@
    1.33  
    1.34    The filter is protypted as:
    1.35  */
    1.36 -typedef int (SDLCALL * SDL_EventFilter) (const SDL_Event * event);
    1.37 +typedef int (SDLCALL * SDL_EventFilter) (SDL_Event * event);
    1.38  /*
    1.39    If the filter returns 1, then the event will be added to the internal queue.
    1.40    If it returns 0, then the event will be dropped from the queue, but the 
     2.1 --- a/include/SDL_keyboard.h	Sun Jun 18 07:31:45 2006 +0000
     2.2 +++ b/include/SDL_keyboard.h	Sun Jun 18 13:47:19 2006 +0000
     2.3 @@ -52,6 +52,7 @@
     2.4      Uint8 padding[3];           /**< alignment padding */
     2.5      Uint16 sym;                 /**< SDL virtual keysym */
     2.6      Uint16 mod;                 /**< current key modifiers */
     2.7 +    Uint32 unicode;             /**< OBSOLETE, use SDL_CharEvent instead */
     2.8  } SDL_keysym;
     2.9  
    2.10  /* Function prototypes */
     3.1 --- a/src/SDL_compat.c	Sun Jun 18 07:31:45 2006 +0000
     3.2 +++ b/src/SDL_compat.c	Sun Jun 18 13:47:19 2006 +0000
     3.3 @@ -150,10 +150,10 @@
     3.4      return modes;
     3.5  }
     3.6  
     3.7 -static int (*orig_eventfilter) (const SDL_Event * event);
     3.8 +static int (*orig_eventfilter) (SDL_Event * event);
     3.9  
    3.10  static int
    3.11 -SDL_CompatEventFilter(const SDL_Event * event)
    3.12 +SDL_CompatEventFilter(SDL_Event * event)
    3.13  {
    3.14      SDL_Event fake;
    3.15  
    3.16 @@ -203,6 +203,24 @@
    3.17              SDL_PushEvent(&fake);
    3.18              break;
    3.19          }
    3.20 +    case SDL_KEYDOWN:
    3.21 +    case SDL_KEYUP:
    3.22 +        {
    3.23 +            Uint32 unicode = 0;
    3.24 +            if (event->key.type == SDL_KEYDOWN && event->key.keysym.sym < 256) {
    3.25 +                int shifted = !!(event->key.keysym.mod & KMOD_SHIFT);
    3.26 +                int capslock = !!(event->key.keysym.mod & KMOD_CAPS);
    3.27 +                if ((shifted ^ capslock) != 0) {
    3.28 +                    unicode = SDL_toupper(event->key.keysym.sym);
    3.29 +                } else {
    3.30 +                    unicode = event->key.keysym.sym;
    3.31 +                }
    3.32 +            }
    3.33 +            if (unicode) {
    3.34 +                event->key.keysym.unicode = unicode;
    3.35 +            }
    3.36 +            break;
    3.37 +        }
    3.38      }
    3.39      if (orig_eventfilter) {
    3.40          return orig_eventfilter(event);
    3.41 @@ -228,7 +246,7 @@
    3.42  SDL_Surface *
    3.43  SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags)
    3.44  {
    3.45 -    int (*filter) (const SDL_Event * event);
    3.46 +    int (*filter) (SDL_Event * event);
    3.47      const SDL_DisplayMode *desktop_mode;
    3.48      SDL_DisplayMode mode;
    3.49      int i;
     4.1 --- a/test/testwm.c	Sun Jun 18 07:31:45 2006 +0000
     4.2 +++ b/test/testwm.c	Sun Jun 18 13:47:19 2006 +0000
     4.3 @@ -176,7 +176,7 @@
     4.4  }
     4.5  
     4.6  int SDLCALL
     4.7 -FilterEvents(const SDL_Event * event)
     4.8 +FilterEvents(SDL_Event * event)
     4.9  {
    4.10      static int reallyquit = 0;
    4.11