Mercurial > sdl-ios-xcode
annotate include/SDL_keyboard.h @ 1674:7688a73b25b1 SDL-1.3
Finishing up keyboard code revamp, at least for now...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 11 Jun 2006 05:27:10 +0000 |
parents | 624e1412fbba |
children | 8d7fecceb9ef |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
911
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
911
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
911
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
911
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
911
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
911
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
911
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
251
b8688cfdc232
Updated the headers with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
0
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
22 | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
23 /** |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
24 * \file SDL_keyboard.h |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
25 * |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
26 * Include file for SDL keyboard event handling |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
27 */ |
0 | 28 |
29 #ifndef _SDL_keyboard_h | |
30 #define _SDL_keyboard_h | |
31 | |
1356
67114343400d
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
32 #include "SDL_stdinc.h" |
1358
c71e05b4dc2e
More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents:
1356
diff
changeset
|
33 #include "SDL_error.h" |
0 | 34 #include "SDL_keysym.h" |
35 | |
36 #include "begin_code.h" | |
37 /* Set up for C function definitions, even when using C++ */ | |
38 #ifdef __cplusplus | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
39 /* *INDENT-OFF* */ |
0 | 40 extern "C" { |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
41 /* *INDENT-ON* */ |
0 | 42 #endif |
43 | |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
44 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
45 * \struct SDL_keysym |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
46 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
47 * \brief The SDL keysym structure, used in key events. |
0 | 48 */ |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
49 typedef struct SDL_keysym |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
50 { |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
51 Uint8 scancode; /**< keyboard specific scancode */ |
1674
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
52 Uint8 padding[3]; /**< alignment padding */ |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
53 Uint16 sym; /**< SDL virtual keysym */ |
7688a73b25b1
Finishing up keyboard code revamp, at least for now...
Sam Lantinga <slouken@libsdl.org>
parents:
1673
diff
changeset
|
54 Uint16 mod; /**< current key modifiers */ |
0 | 55 } SDL_keysym; |
56 | |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
57 /* Function prototypes */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
58 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
59 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
60 * \fn int SDL_GetNumKeyboards(void) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
61 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
62 * \brief Get the number of keyboard input devices available. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
63 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
64 * \sa SDL_SelectKeyboard() |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
65 */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
66 extern DECLSPEC int SDLCALL SDL_GetNumKeyboards(void); |
0 | 67 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
68 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
69 * \fn int SDL_SelectKeyboard(int index) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
70 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
71 * \brief Set the index of the currently selected keyboard. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
72 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
73 * \return The index of the previously selected keyboard. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
74 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
75 * \note You can query the currently selected keyboard by passing an index of -1. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
76 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
77 * \sa SDL_GetNumKeyboards() |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
78 */ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
79 extern DECLSPEC int SDLCALL SDL_SelectKeyboard(int index); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
80 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
81 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
82 * \fn int SDL_EnableUNICODE(int enable) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
83 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
84 * \brief Enable/Disable UNICODE translation of keyboard input. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
85 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
86 * \param enable 1 to enable translation, 0 to disable translation, -1 to query translation |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
87 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
88 * \return The previous state of keyboard translation |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
89 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
90 * \note This translation has some overhead, so translation defaults off. |
0 | 91 */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
92 extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); |
0 | 93 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
94 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
95 * \fn int SDL_EnableKeyRepeat(int delay, int interval) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
96 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
97 * \brief Enable keyboard repeat for the selected keyboard. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
98 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
99 * \param delay The initial delay in milliseconds between the time when a |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
100 * key is pressed and keyboard repeat begins. Setting a delay |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
101 * of 0 will disable keyboard repeat. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
102 * \param interval The time in milliseconds between keyboard repeat events. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
103 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
104 * \return 0 on success, or -1 if there was an error. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
105 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
106 * \note Keyboard repeat defaults to off. |
0 | 107 */ |
108 #define SDL_DEFAULT_REPEAT_DELAY 500 | |
109 #define SDL_DEFAULT_REPEAT_INTERVAL 30 | |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
110 /**/ |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
111 extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
112 |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
113 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
114 * \fn void SDL_GetKeyRepeat(int *delay, int *interval) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
115 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
116 * \brief Get the current keyboard repeat setting for the selected keyboard. |
0 | 117 */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
118 extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); |
0 | 119 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
120 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
121 * \fn Uint8 *SDL_GetKeyState(int *numkeys) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
122 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
123 * \brief Get a snapshot of the current state of the selected keyboard. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
124 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
125 * \return An array of keystates, indexed by the SDLK_* syms. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
126 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
127 * Example: |
0 | 128 * Uint8 *keystate = SDL_GetKeyState(NULL); |
129 * if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed. | |
130 */ | |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
131 extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyState(int *numkeys); |
0 | 132 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
133 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
134 * \fn SDLMod SDL_GetModState(void) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
135 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
136 * \brief Get the current key modifier state for the selected keyboard. |
0 | 137 */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
138 extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); |
0 | 139 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
140 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
141 * \fn void SDL_SetModState(SDLMod modstate) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
142 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
143 * \brief Set the current key modifier state for the selected keyboard. |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
144 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
145 * \note This does not change the keyboard state, only the key modifier flags. |
0 | 146 */ |
1668
4da1ee79c9af
more tweaking indent options
Sam Lantinga <slouken@libsdl.org>
parents:
1662
diff
changeset
|
147 extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); |
0 | 148 |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
149 /** |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
150 * \fn const char *SDL_GetKeyName(SDLKey key) |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
151 * |
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
152 * \brief Get the name of an SDL virtual keysym |
0 | 153 */ |
1673
624e1412fbba
Keyboard code update in progress
Sam Lantinga <slouken@libsdl.org>
parents:
1668
diff
changeset
|
154 extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key); |
0 | 155 |
156 | |
157 /* Ends C function definitions when using C++ */ | |
158 #ifdef __cplusplus | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
159 /* *INDENT-OFF* */ |
0 | 160 } |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
161 /* *INDENT-ON* */ |
0 | 162 #endif |
163 #include "close_code.h" | |
164 | |
165 #endif /* _SDL_keyboard_h */ | |
1662
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
166 |
782fd950bd46
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
Sam Lantinga <slouken@libsdl.org>
parents:
1507
diff
changeset
|
167 /* vi: set ts=4 sw=4 expandtab: */ |