Merged a cleaned up version of Jiang's code changes from Google Summer of Code 2009

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403823
This commit is contained in:
Sam Lantinga 2009-09-19 13:29:40 +00:00
parent c03508fe86
commit d4f133c2bf
17 changed files with 605 additions and 14 deletions

View file

@ -60,6 +60,7 @@ typedef enum
SDL_WINDOWEVENT, /**< Window state change */
SDL_KEYDOWN, /**< Keys pressed */
SDL_KEYUP, /**< Keys released */
SDL_TEXTEDITING, /**< Keyboard text editing (composition) */
SDL_TEXTINPUT, /**< Keyboard text input */
SDL_MOUSEMOTION, /**< Mouse moved */
SDL_MOUSEBUTTONDOWN, /**< Mouse button pressed */
@ -97,6 +98,7 @@ typedef enum
SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP),
SDL_TEXTEDITINGMASK = SDL_EVENTMASK(SDL_TEXTEDITING),
SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT),
SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
@ -148,6 +150,20 @@ typedef struct SDL_KeyboardEvent
SDL_keysym keysym; /**< The key that was pressed or released */
} SDL_KeyboardEvent;
/**
* \struct SDL_TextEditingEvent
*
* \brief Keyboard text editing event structure (event.edit.*)
*/
#define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
typedef struct SDL_TextEditingEvent
{
Uint8 type; /**< SDL_TEXTEDITING */
char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE]; /**< The editing text */
int start; /**< The start cursor of selected editing text */
int length; /**< The length of selected editing text */
} SDL_TextEditingEvent;
/**
* \struct SDL_TextInputEvent
*
@ -350,6 +366,7 @@ typedef union SDL_Event
Uint8 type; /**< Event type, shared with all events */
SDL_WindowEvent window; /**< Window event data */
SDL_KeyboardEvent key; /**< Keyboard event data */
SDL_TextEditingEvent edit; /**< Text editing event data */
SDL_TextInputEvent text; /**< Text input event data */
SDL_MouseMotionEvent motion; /**< Mouse motion event data */
SDL_MouseButtonEvent button; /**< Mouse button event data */

View file

@ -154,6 +154,34 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
*/
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
/**
* \fn void SDL_StartTextInput(void)
*
* \brief Start accepting Unicode text input events.
*
* \sa SDL_StopTextInput()
* \sa SDL_SetTextInputRect()
*/
extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
/**
* \fn void SDL_StopTextInput(void)
*
* \brief Stop receiving any text input events.
*
* \sa SDL_StartTextInput()
*/
extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
/**
* \fn void SDL_SetTextInputRect(SDL_Rect *rect)
*
* \brief Set the rectangle used to type Unicode text inputs.
*
* \sa SDL_StartTextInput()
*/
extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus