File: keyboard.html

package info (click to toggle)
allegro5 2%3A5.0.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 14,856 kB
  • ctags: 15,948
  • sloc: ansic: 87,540; cpp: 9,693; objc: 3,491; python: 2,057; sh: 829; makefile: 93; perl: 37; pascal: 24
file content (248 lines) | stat: -rw-r--r-- 10,473 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title>Keyboard routines</title>
  <style type="text/css">code{white-space: pre;}</style>
  <link rel="stylesheet" href="pandoc.css" type="text/css" />
  <script type="text/javascript" src="autosuggest.js"></script>
  <script type="text/javascript" src="search_index.js"></script>
</head>
<body>
<div class="sidebar">

<div>
<ul>
<li><a href="index.html"><strong>Contents</strong></a></li>
<li><a href="config.html">Configuration files</a></li>
<li><a href="display.html">Display</a></li>
<li><a href="events.html">Events</a></li>
<li><a href="file.html">File I/O</a></li>
<li><a href="fshook.html">Filesystem</a></li>
<li><a href="fixed.html">Fixed point math</a></li>
<li><a href="fullscreen_mode.html">Fullscreen modes</a></li>
<li><a href="graphics.html">Graphics</a></li>
<li><a href="joystick.html">Joystick</a></li>
<li><a href="keyboard.html">Keyboard</a></li>
<li><a href="memory.html">Memory</a></li>
<li><a href="monitor.html">Monitor</a></li>
<li><a href="mouse.html">Mouse</a></li>
<li><a href="path.html">Path</a></li>
<li><a href="state.html">State</a></li>
<li><a href="system.html">System</a></li>
<li><a href="threads.html">Threads</a></li>
<li><a href="time.html">Time</a></li>
<li><a href="timer.html">Timer</a></li>
<li><a href="transformations.html">Transformations</a></li>
<li><a href="utf8.html">UTF-8</a></li>
<li><a href="misc.html">Miscellaneous</a></li>
<li><a href="platform.html">Platform-specific</a></li>
<li><a href="direct3d.html">Direct3D</a></li>
<li><a href="opengl.html">OpenGL</a></li>
</ul>
<!-- The preceding blank line forces pandoc to terminate the list -->
</div>

<div>
<ul>
<li><a href="index.html#addons"><strong>Addons</strong></a></li>
<li><a href="audio.html">Audio addon</a></li>
<li><a href="acodec.html">Audio codecs</a></li>
<li><a href="color.html">Color addon</a></li>
<li><a href="font.html">Font addons</a></li>
<li><a href="image.html">Image I/O addon</a></li>
<li><a href="main.html">Main addon</a></li>
<li><a href="memfile.html">Memfile addon</a></li>
<li><a href="native_dialog.html">Native dialogs addon</a></li>
<li><a href="physfs.html">PhysicsFS addon</a></li>
<li><a href="primitives.html">Primitives addon</a></li>
</ul>
<!-- The preceding blank line forces pandoc to terminate the list -->
</div>

<div>
<ul>
<li><a href="index_all.html"><strong>Index</strong></a></li>
</ul>
<!-- The preceding blank line forces pandoc to terminate the list -->
</div>

<div class="searchbox">
<script type="text/javascript">
function on_search(index, control) {
    // Note to self: the less-than sign must NOT converted to an entity!
    // SCRIPT elements are special.  The HTML validator gives bad advice.
    for (i = 0; i < search_index.length; i++) {
        if (search_index[i] == control.keywords[index]) {
            break;
        }
    }
    location.href = search_urls[i];
}
</script>
Search<br/> <input type="text" name="q" id="q" size="15" autocomplete="off"/><br/>
<script type="text/javascript"> new autosuggest("q", search_index, null, on_search); </script>
</div>

</div>

<div class="content">



<div id="header">
<h1 class="title">Keyboard routines</h1>
</div>
<div id="TOC">
<ul>
<li><a href="#allegro_keyboard_state">ALLEGRO_KEYBOARD_STATE</a></li>
<li><a href="#key-codes">Key codes</a></li>
<li><a href="#keyboard-modifier-flags">Keyboard modifier flags</a></li>
<li><a href="#al_install_keyboard">al_install_keyboard</a></li>
<li><a href="#al_is_keyboard_installed">al_is_keyboard_installed</a></li>
<li><a href="#al_uninstall_keyboard">al_uninstall_keyboard</a></li>
<li><a href="#al_get_keyboard_state">al_get_keyboard_state</a></li>
<li><a href="#al_key_down">al_key_down</a></li>
<li><a href="#al_keycode_to_name">al_keycode_to_name</a></li>
<li><a href="#al_set_keyboard_leds">al_set_keyboard_leds</a></li>
<li><a href="#al_get_keyboard_event_source">al_get_keyboard_event_source</a></li>
</ul>
</div>
<p>These functions are declared in the main Allegro header file:</p>
<pre><code>#include &lt;allegro5/allegro.h&gt;</code></pre>
<h1 id="allegro_keyboard_state"><a href="#allegro_keyboard_state">ALLEGRO_KEYBOARD_STATE</a></h1>
<pre><code>typedef struct ALLEGRO_KEYBOARD_STATE ALLEGRO_KEYBOARD_STATE;</code></pre>
<p>This is a structure that is used to hold a &quot;snapshot&quot; of a keyboard's state at a particular instant. It contains the following publically readable fields:</p>
<ul>
<li>display - points to the display that had keyboard focus at the time the state was saved. If no display was focused, this points to NULL.</li>
</ul>
<p>You cannot read the state of keys directly. Use the function <a href="keyboard.html#al_key_down">al_key_down</a>.</p>
<h1 id="key-codes"><a href="#key-codes">Key codes</a></h1>
<p>The constant ALLEGRO_KEY_MAX is always one higher than the highest key code. So if you want to use the key code as array index you can do something like this:</p>
<pre><code>bool pressed_keys[ALLEGRO_KEY_MAX];
...
pressed_keys[key_code] = true;</code></pre>
<p>These are the list of key codes used by Allegro, which are returned in the event.keyboard.keycode field of the ALLEGRO_KEY_DOWN and ALLEGRO_KEY_UP events and which you can pass to <a href="keyboard.html#al_key_down">al_key_down</a>:</p>
<pre><code>ALLEGRO_KEY_A ... ALLEGRO_KEY_Z
ALLEGRO_KEY_0 ... ALLEGRO_KEY_9
ALLEGRO_KEY_PAD_0 ... ALLEGRO_KEY_PAD_9
ALLEGRO_KEY_F1 ... ALLEGRO_KEY_F12
ALLEGRO_KEY_ESCAPE
ALLEGRO_KEY_TILDE
ALLEGRO_KEY_MINUS
ALLEGRO_KEY_EQUALS
ALLEGRO_KEY_BACKSPACE
ALLEGRO_KEY_TAB
ALLEGRO_KEY_OPENBRACE
ALLEGRO_KEY_CLOSEBRACE
ALLEGRO_KEY_ENTER
ALLEGRO_KEY_SEMICOLON
ALLEGRO_KEY_QUOTE
ALLEGRO_KEY_BACKSLASH
ALLEGRO_KEY_BACKSLASH2
ALLEGRO_KEY_COMMA
ALLEGRO_KEY_FULLSTOP
ALLEGRO_KEY_SLASH
ALLEGRO_KEY_SPACE
ALLEGRO_KEY_INSERT
ALLEGRO_KEY_DELETE
ALLEGRO_KEY_HOME
ALLEGRO_KEY_END
ALLEGRO_KEY_PGUP
ALLEGRO_KEY_PGDN
ALLEGRO_KEY_LEFT
ALLEGRO_KEY_RIGHT
ALLEGRO_KEY_UP
ALLEGRO_KEY_DOWN
ALLEGRO_KEY_PAD_SLASH
ALLEGRO_KEY_PAD_ASTERISK
ALLEGRO_KEY_PAD_MINUS
ALLEGRO_KEY_PAD_PLUS
ALLEGRO_KEY_PAD_DELETE
ALLEGRO_KEY_PAD_ENTER
ALLEGRO_KEY_PRINTSCREEN
ALLEGRO_KEY_PAUSE
ALLEGRO_KEY_ABNT_C1
ALLEGRO_KEY_YEN
ALLEGRO_KEY_KANA
ALLEGRO_KEY_CONVERT
ALLEGRO_KEY_NOCONVERT
ALLEGRO_KEY_AT
ALLEGRO_KEY_CIRCUMFLEX
ALLEGRO_KEY_COLON2
ALLEGRO_KEY_KANJI
ALLEGRO_KEY_LSHIFT
ALLEGRO_KEY_RSHIFT
ALLEGRO_KEY_LCTRL
ALLEGRO_KEY_RCTRL
ALLEGRO_KEY_ALT
ALLEGRO_KEY_ALTGR
ALLEGRO_KEY_LWIN
ALLEGRO_KEY_RWIN
ALLEGRO_KEY_MENU
ALLEGRO_KEY_SCROLLLOCK
ALLEGRO_KEY_NUMLOCK
ALLEGRO_KEY_CAPSLOCK
ALLEGRO_KEY_PAD_EQUALS
ALLEGRO_KEY_BACKQUOTE
ALLEGRO_KEY_SEMICOLON2
ALLEGRO_KEY_COMMAND</code></pre>
<h1 id="keyboard-modifier-flags"><a href="#keyboard-modifier-flags">Keyboard modifier flags</a></h1>
<pre><code>ALLEGRO_KEYMOD_SHIFT
ALLEGRO_KEYMOD_CTRL
ALLEGRO_KEYMOD_ALT
ALLEGRO_KEYMOD_LWIN
ALLEGRO_KEYMOD_RWIN
ALLEGRO_KEYMOD_MENU
ALLEGRO_KEYMOD_ALTGR
ALLEGRO_KEYMOD_COMMAND
ALLEGRO_KEYMOD_SCROLLLOCK
ALLEGRO_KEYMOD_NUMLOCK
ALLEGRO_KEYMOD_CAPSLOCK
ALLEGRO_KEYMOD_INALTSEQ
ALLEGRO_KEYMOD_ACCENT1
ALLEGRO_KEYMOD_ACCENT2
ALLEGRO_KEYMOD_ACCENT3
ALLEGRO_KEYMOD_ACCENT4</code></pre>
<p>The event field 'keyboard.modifiers' is a bitfield composed of these constants. These indicate the modifier keys which were pressed at the time a character was typed.</p>
<h1 id="al_install_keyboard"><a href="#al_install_keyboard">al_install_keyboard</a></h1>
<pre><code>bool al_install_keyboard(void)</code></pre>
<p>Install a keyboard driver. Returns true if successful. If a driver was already installed, nothing happens and true is returned.</p>
<p>See also: <a href="keyboard.html#al_uninstall_keyboard">al_uninstall_keyboard</a>, <a href="keyboard.html#al_is_keyboard_installed">al_is_keyboard_installed</a></p>
<h1 id="al_is_keyboard_installed"><a href="#al_is_keyboard_installed">al_is_keyboard_installed</a></h1>
<pre><code>bool al_is_keyboard_installed(void)</code></pre>
<p>Returns true if <a href="keyboard.html#al_install_keyboard">al_install_keyboard</a> was called successfully.</p>
<h1 id="al_uninstall_keyboard"><a href="#al_uninstall_keyboard">al_uninstall_keyboard</a></h1>
<pre><code>void al_uninstall_keyboard(void)</code></pre>
<p>Uninstalls the active keyboard driver, if any. This will automatically unregister the keyboard event source with any event queues.</p>
<p>This function is automatically called when Allegro is shut down.</p>
<p>See also: <a href="keyboard.html#al_install_keyboard">al_install_keyboard</a></p>
<h1 id="al_get_keyboard_state"><a href="#al_get_keyboard_state">al_get_keyboard_state</a></h1>
<pre><code>void al_get_keyboard_state(ALLEGRO_KEYBOARD_STATE *ret_state)</code></pre>
<p>Save the state of the keyboard specified at the time the function is called into the structure pointed to by <em>ret_state</em>.</p>
<p>See also: <a href="keyboard.html#al_key_down">al_key_down</a>, <a href="keyboard.html#allegro_keyboard_state">ALLEGRO_KEYBOARD_STATE</a></p>
<h1 id="al_key_down"><a href="#al_key_down">al_key_down</a></h1>
<pre><code>bool al_key_down(const ALLEGRO_KEYBOARD_STATE *state, int keycode)</code></pre>
<p>Return true if the key specified was held down in the state specified.</p>
<p>See also: <a href="keyboard.html#allegro_keyboard_state">ALLEGRO_KEYBOARD_STATE</a></p>
<h1 id="al_keycode_to_name"><a href="#al_keycode_to_name">al_keycode_to_name</a></h1>
<pre><code>const char *al_keycode_to_name(int keycode)</code></pre>
<p>Converts the given keycode to a description of the key.</p>
<h1 id="al_set_keyboard_leds"><a href="#al_set_keyboard_leds">al_set_keyboard_leds</a></h1>
<pre><code>bool al_set_keyboard_leds(int leds)</code></pre>
<p>Overrides the state of the keyboard LED indicators. Set to -1 to return to default behavior. False is returned if the current keyboard driver cannot set LED indicators.</p>
<h1 id="al_get_keyboard_event_source"><a href="#al_get_keyboard_event_source">al_get_keyboard_event_source</a></h1>
<pre><code>ALLEGRO_EVENT_SOURCE *al_get_keyboard_event_source(void)</code></pre>
<p>Retrieve the keyboard event source.</p>
<p>Returns NULL if the keyboard subsystem was not installed.</p>
<p class="timestamp">
Allegro version 5.0.10
 - Last updated: 2013-06-16 03:32:10 UTC
</p>
</div>


</body>
</html>