2001-04-26 16:45:43 +00:00
|
|
|
/*
|
|
|
|
SDL - Simple DirectMedia Layer
|
2010-01-24 21:10:53 +00:00
|
|
|
Copyright (C) 1997-2010 Sam Lantinga
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2006-02-01 06:32:25 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
2001-04-26 16:45:43 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2006-02-01 06:32:25 +00:00
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2006-02-01 06:32:25 +00:00
|
|
|
Lesser General Public License for more details.
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-02-01 06:32:25 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
Sam Lantinga
|
2001-12-14 12:37:47 +00:00
|
|
|
slouken@libsdl.org
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \file SDL_keyboard.h
|
|
|
|
*
|
|
|
|
* Include file for SDL keyboard event handling
|
2006-07-10 21:04:37 +00:00
|
|
|
*/
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
#ifndef _SDL_keyboard_h
|
|
|
|
#define _SDL_keyboard_h
|
|
|
|
|
2006-02-10 03:19:02 +00:00
|
|
|
#include "SDL_stdinc.h"
|
2006-02-10 06:48:43 +00:00
|
|
|
#include "SDL_error.h"
|
2001-04-26 16:45:43 +00:00
|
|
|
#include "SDL_keysym.h"
|
|
|
|
|
|
|
|
#include "begin_code.h"
|
|
|
|
/* Set up for C function definitions, even when using C++ */
|
|
|
|
#ifdef __cplusplus
|
2006-07-10 21:04:37 +00:00
|
|
|
/* *INDENT-OFF* */
|
2001-04-26 16:45:43 +00:00
|
|
|
extern "C" {
|
2006-07-10 21:04:37 +00:00
|
|
|
/* *INDENT-ON* */
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief The SDL keysym structure, used in key events.
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
2006-07-10 21:04:37 +00:00
|
|
|
typedef struct SDL_keysym
|
|
|
|
{
|
2008-02-05 07:19:23 +00:00
|
|
|
SDL_scancode scancode; /**< SDL physical key code - see ::SDL_scancode for details */
|
Date: Thu, 05 Jul 2007 14:02:33 -0700
From: Sam Lantinga
Subject: SDL 1.3 keyboard plan
After lots of discussion with Christian, this is what we came up with:
> So, to sum up...
> SDLK_* become the physical keys, starting at > (1<<21)
> We create a macro SDLK_INDEX(X)
> We have two functions SDL_GetLayoutKey(SDLKey) and SDL_GetKeyName()
> SDL_GetLayoutKey maps to UCS4 for printable characters, and SDLK* for
non-printable characters
> and does so based on the OS's current keyboard layout
> SDL_GetKeyName() handles both SDLK_* and UCS4, converting UCS4 to UTF-8 and
converting SDLK_* into our names, which are UTF-8 for printable characters.
> WASD folks use SDLK_*, and 'I' folks use SDL_GetLayoutKey(SDLK_*)
Here is the patch he came up with, and his e-mail about it:
Date: Fri, 17 Aug 2007 19:50:28 +0200
From: Christian Walther
Subject: Re: SDL 1.3 keyboard plan
> Sounds great, go ahead and send me a patch.
Here goes! Thanks for having a look. Don't hesitate to comment if
anything does not conform to your ideas.
One caveat: Committing this now may break compilability of some video
drivers - specifically, if they use any of the SDLK_* codes that were
obsoleted and moved into SDL_compat.h. I only tried Cocoa (which did
break, but is already fixed) and X11 (which didn't, but then its key
handling is #iffed out). If that's a problem, it may need to go into
a branch.
-Christian
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402630
2007-08-19 14:52:52 +00:00
|
|
|
SDLKey sym; /**< SDL virtual key code - see ::SDLKey for details */
|
2006-07-10 21:04:37 +00:00
|
|
|
Uint16 mod; /**< current key modifiers */
|
2009-10-19 13:31:58 +00:00
|
|
|
Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */
|
2001-04-26 16:45:43 +00:00
|
|
|
} SDL_keysym;
|
|
|
|
|
|
|
|
/* Function prototypes */
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Get the number of keyboard input devices available.
|
|
|
|
*
|
|
|
|
* \sa SDL_SelectKeyboard()
|
2006-07-10 21:04:37 +00:00
|
|
|
*/
|
|
|
|
extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void);
|
|
|
|
|
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Set the index of the currently selected keyboard.
|
|
|
|
*
|
|
|
|
* \return The index of the previously selected keyboard.
|
|
|
|
*
|
|
|
|
* \note You can query the currently selected keyboard by passing an index of -1.
|
|
|
|
*
|
|
|
|
* \sa SDL_GetNumKeyboards()
|
2006-07-10 21:04:37 +00:00
|
|
|
*/
|
|
|
|
extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index);
|
|
|
|
|
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Get a snapshot of the current state of the selected keyboard.
|
|
|
|
*
|
|
|
|
* \param numkeys if non-NULL, receives the length of the returned array.
|
|
|
|
*
|
|
|
|
* \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
|
|
|
|
*
|
|
|
|
* \b Example:
|
|
|
|
* \code
|
|
|
|
* Uint8 *state = SDL_GetKeyboardState(NULL);
|
|
|
|
* if ( state[SDL_SCANCODE_RETURN] ) {
|
|
|
|
* printf("<RETURN> is pressed.\n");
|
|
|
|
* }
|
|
|
|
* \endcode
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
2008-02-05 07:19:23 +00:00
|
|
|
extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys);
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Get the current key modifier state for the selected keyboard.
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
2002-04-11 14:35:16 +00:00
|
|
|
extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void);
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Set the current key modifier state for the selected keyboard.
|
|
|
|
*
|
|
|
|
* \note This does not change the keyboard state, only the key modifier flags.
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
2002-04-11 14:35:16 +00:00
|
|
|
extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate);
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2006-07-10 21:04:37 +00:00
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Get the key code corresponding to the given scancode according to the
|
|
|
|
* current keyboard layout.
|
|
|
|
*
|
|
|
|
* See ::SDLKey for details.
|
|
|
|
*
|
|
|
|
* \sa SDL_GetKeyName()
|
Date: Thu, 05 Jul 2007 14:02:33 -0700
From: Sam Lantinga
Subject: SDL 1.3 keyboard plan
After lots of discussion with Christian, this is what we came up with:
> So, to sum up...
> SDLK_* become the physical keys, starting at > (1<<21)
> We create a macro SDLK_INDEX(X)
> We have two functions SDL_GetLayoutKey(SDLKey) and SDL_GetKeyName()
> SDL_GetLayoutKey maps to UCS4 for printable characters, and SDLK* for
non-printable characters
> and does so based on the OS's current keyboard layout
> SDL_GetKeyName() handles both SDLK_* and UCS4, converting UCS4 to UTF-8 and
converting SDLK_* into our names, which are UTF-8 for printable characters.
> WASD folks use SDLK_*, and 'I' folks use SDL_GetLayoutKey(SDLK_*)
Here is the patch he came up with, and his e-mail about it:
Date: Fri, 17 Aug 2007 19:50:28 +0200
From: Christian Walther
Subject: Re: SDL 1.3 keyboard plan
> Sounds great, go ahead and send me a patch.
Here goes! Thanks for having a look. Don't hesitate to comment if
anything does not conform to your ideas.
One caveat: Committing this now may break compilability of some video
drivers - specifically, if they use any of the SDLK_* codes that were
obsoleted and moved into SDL_compat.h. I only tried Cocoa (which did
break, but is already fixed) and X11 (which didn't, but then its key
handling is #iffed out). If that's a problem, it may need to go into
a branch.
-Christian
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402630
2007-08-19 14:52:52 +00:00
|
|
|
*/
|
2008-02-05 07:19:23 +00:00
|
|
|
extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
|
Date: Thu, 05 Jul 2007 14:02:33 -0700
From: Sam Lantinga
Subject: SDL 1.3 keyboard plan
After lots of discussion with Christian, this is what we came up with:
> So, to sum up...
> SDLK_* become the physical keys, starting at > (1<<21)
> We create a macro SDLK_INDEX(X)
> We have two functions SDL_GetLayoutKey(SDLKey) and SDL_GetKeyName()
> SDL_GetLayoutKey maps to UCS4 for printable characters, and SDLK* for
non-printable characters
> and does so based on the OS's current keyboard layout
> SDL_GetKeyName() handles both SDLK_* and UCS4, converting UCS4 to UTF-8 and
converting SDLK_* into our names, which are UTF-8 for printable characters.
> WASD folks use SDLK_*, and 'I' folks use SDL_GetLayoutKey(SDLK_*)
Here is the patch he came up with, and his e-mail about it:
Date: Fri, 17 Aug 2007 19:50:28 +0200
From: Christian Walther
Subject: Re: SDL 1.3 keyboard plan
> Sounds great, go ahead and send me a patch.
Here goes! Thanks for having a look. Don't hesitate to comment if
anything does not conform to your ideas.
One caveat: Committing this now may break compilability of some video
drivers - specifically, if they use any of the SDLK_* codes that were
obsoleted and moved into SDL_compat.h. I only tried Cocoa (which did
break, but is already fixed) and X11 (which didn't, but then its key
handling is #iffed out). If that's a problem, it may need to go into
a branch.
-Christian
--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402630
2007-08-19 14:52:52 +00:00
|
|
|
|
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Get the scancode corresponding to the given key code according to the
|
|
|
|
* current keyboard layout.
|
|
|
|
*
|
|
|
|
* See ::SDL_scancode for details.
|
|
|
|
*
|
|
|
|
* \sa SDL_GetScancodeName()
|
2008-02-05 07:19:23 +00:00
|
|
|
*/
|
|
|
|
extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
|
|
|
|
|
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Get a human-readable name for a scancode.
|
|
|
|
*
|
|
|
|
* \return A pointer to a UTF-8 string that stays valid at least until the next
|
|
|
|
* call to this function. If you need it around any longer, you must
|
|
|
|
* copy it. If the scancode doesn't have a name, this function returns
|
|
|
|
* an empty string ("").
|
|
|
|
*
|
|
|
|
* \sa SDL_scancode
|
2008-02-05 07:19:23 +00:00
|
|
|
*/
|
|
|
|
extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
|
|
|
|
scancode);
|
|
|
|
|
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Get a human-readable name for a key.
|
|
|
|
*
|
|
|
|
* \return A pointer to a UTF-8 string that stays valid at least until the next
|
|
|
|
* call to this function. If you need it around any longer, you must
|
|
|
|
* copy it. If the key doesn't have a name, this function returns an
|
|
|
|
* empty string ("").
|
|
|
|
*
|
|
|
|
* \sa SDLKey
|
2001-04-26 16:45:43 +00:00
|
|
|
*/
|
2008-02-05 07:19:23 +00:00
|
|
|
extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key);
|
2001-04-26 16:45:43 +00:00
|
|
|
|
2009-09-19 13:29:40 +00:00
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Start accepting Unicode text input events.
|
|
|
|
*
|
|
|
|
* \sa SDL_StopTextInput()
|
|
|
|
* \sa SDL_SetTextInputRect()
|
2009-09-19 13:29:40 +00:00
|
|
|
*/
|
|
|
|
extern DECLSPEC void SDLCALL SDL_StartTextInput(void);
|
|
|
|
|
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Stop receiving any text input events.
|
|
|
|
*
|
|
|
|
* \sa SDL_StartTextInput()
|
2009-09-19 13:29:40 +00:00
|
|
|
*/
|
|
|
|
extern DECLSPEC void SDLCALL SDL_StopTextInput(void);
|
|
|
|
|
|
|
|
/**
|
2009-10-19 13:31:58 +00:00
|
|
|
* \brief Set the rectangle used to type Unicode text inputs.
|
|
|
|
*
|
|
|
|
* \sa SDL_StartTextInput()
|
2009-09-19 13:29:40 +00:00
|
|
|
*/
|
|
|
|
extern DECLSPEC void SDLCALL SDL_SetTextInputRect(SDL_Rect *rect);
|
|
|
|
|
2001-04-26 16:45:43 +00:00
|
|
|
|
|
|
|
/* Ends C function definitions when using C++ */
|
|
|
|
#ifdef __cplusplus
|
2006-07-10 21:04:37 +00:00
|
|
|
/* *INDENT-OFF* */
|
2001-04-26 16:45:43 +00:00
|
|
|
}
|
2006-07-10 21:04:37 +00:00
|
|
|
/* *INDENT-ON* */
|
2001-04-26 16:45:43 +00:00
|
|
|
#endif
|
|
|
|
#include "close_code.h"
|
|
|
|
|
|
|
|
#endif /* _SDL_keyboard_h */
|
2006-07-10 21:04:37 +00:00
|
|
|
|
|
|
|
/* vi: set ts=4 sw=4 expandtab: */
|