File: ALLEGRO_EVENT_DISPLAY_FOUND.3

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 (550 lines) | stat: -rw-r--r-- 11,781 bytes parent folder | download | duplicates (23)
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
.TH ALLEGRO_EVENT 3 "" "Allegro reference manual"
.SH NAME
.PP
ALLEGRO_EVENT \- Allegro 5 API
.SH SYNOPSIS
.IP
.nf
\f[C]
#include\ <allegro5/allegro.h>

typedef\ union\ ALLEGRO_EVENT\ ALLEGRO_EVENT;
\f[]
.fi
.SH DESCRIPTION
.PP
An ALLEGRO_EVENT is a union of all builtin event structures, i.e.
it is an object large enough to hold the data of any event type.
All events have the following fields in common:
.TP
.B type (ALLEGRO_EVENT_TYPE)
Indicates the type of event.
.RS
.RE
.TP
.B any.source (ALLEGRO_EVENT_SOURCE *)
The event source which generated the event.
.RS
.RE
.TP
.B any.timestamp (double)
When the event was generated.
.RS
.RE
.PP
By examining the \f[C]type\f[] field you can then access type\-specific
fields.
The \f[C]any.source\f[] field tells you which event source generated
that particular event.
The \f[C]any.timestamp\f[] field tells you when the event was generated.
The time is referenced to the same starting point as al_get_time(3).
.PP
Each event is of one of the following types, with the usable fields
given.
.SS ALLEGRO_EVENT_JOYSTICK_AXIS
.PP
A joystick axis value changed.
.TP
.B joystick.id (ALLEGRO_JOYSTICK *)
The joystick which generated the event.
This is not the same as the event source \f[C]joystick.source\f[].
.RS
.RE
.TP
.B joystick.stick (int)
The stick number, counting from zero.
Axes on a joystick are grouped into "sticks".
.RS
.RE
.TP
.B joystick.axis (int)
The axis number on the stick, counting from zero.
.RS
.RE
.TP
.B joystick.pos (float)
The axis position, from \-1.0 to +1.0.
.RS
.RE
.SS ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN
.PP
A joystick button was pressed.
.TP
.B joystick.id (ALLEGRO_JOYSTICK *)
The joystick which generated the event.
.RS
.RE
.TP
.B joystick.button (int)
The button which was pressed, counting from zero.
.RS
.RE
.SS ALLEGRO_EVENT_JOYSTICK_BUTTON_UP
.PP
A joystick button was released.
.TP
.B joystick.id (ALLEGRO_JOYSTICK *)
The joystick which generated the event.
.RS
.RE
.TP
.B joystick.button (int)
The button which was released, counting from zero.
.RS
.RE
.SS ALLEGRO_EVENT_JOYSTICK_CONFIGURATION
.PP
A joystick was plugged in or unplugged.
See al_reconfigure_joysticks(3) for details.
.SS ALLEGRO_EVENT_KEY_DOWN
.PP
A keyboard key was pressed.
.TP
.B keyboard.keycode (int)
The code corresponding to the physical key which was pressed.
See the "Key codes" section for the list of ALLEGRO_KEY_* constants.
.RS
.RE
.TP
.B keyboard.display (ALLEGRO_DISPLAY *)
The display which had keyboard focus when the event occurred.
.RS
.RE
.RS
.PP
\f[I]Note:\f[] this event is about the physical keys being pressed on
the keyboard.
Look for ALLEGRO_EVENT_KEY_CHAR events for character input.
.RE
.SS ALLEGRO_EVENT_KEY_UP
.PP
A keyboard key was released.
.TP
.B keyboard.keycode (int)
The code corresponding to the physical key which was released.
See the "Key codes" section for the list of ALLEGRO_KEY_* constants.
.RS
.RE
.TP
.B keyboard.display (ALLEGRO_DISPLAY *)
The display which had keyboard focus when the event occurred.
.RS
.RE
.SS ALLEGRO_EVENT_KEY_CHAR
.PP
A character was typed on the keyboard, or a character was
auto\-repeated.
.TP
.B keyboard.keycode (int)
The code corresponding to the physical key which was last pressed.
See the "Key codes" section for the list of ALLEGRO_KEY_* constants.
.RS
.RE
.TP
.B keyboard.unichar (int)
A Unicode code point (character).
This \f[I]may\f[] be zero or negative if the event was generated for a
non\-visible "character", such as an arrow or Function key.
In that case you can act upon the \f[C]keycode\f[] field.
.RS
.PP
Some special keys will set the \f[C]unichar\f[] field to their standard
ASCII values: Tab=9, Return=13, Escape=27.
In addition if you press the Control key together with A to Z the
\f[C]unichar\f[] field will have the values 1 to 26.
For example Ctrl\-A will set \f[C]unichar\f[] to 1 and Ctrl\-H will set
it to 8.
.PP
As of Allegro 5.0.2 there are some inconsistencies in the treatment of
Backspace (8 or 127) and Delete (127 or 0) keys on different platforms.
These can be worked around by checking the \f[C]keycode\f[] field.
.RE
.TP
.B keyboard.modifiers (unsigned)
This is a bitfield of the modifier keys which were pressed when the
event occurred.
See "Keyboard modifier flags" for the constants.
.RS
.RE
.TP
.B keyboard.repeat (bool)
Indicates if this is a repeated character.
.RS
.RE
.TP
.B keyboard.display (ALLEGRO_DISPLAY *)
The display which had keyboard focus when the event occurred.
.RS
.RE
.RS
.PP
\f[I]Note\f[]: in many input methods, characters are \f[I]not\f[]
entered one\-for\-one with physical key presses.
Multiple key presses can combine to generate a single character, e.g.
apostrophe + e may produce \[aq]é\[aq].
Fewer key presses can also generate more characters, e.g.
macro sequences expanding to common phrases.
.RE
.SS ALLEGRO_EVENT_MOUSE_AXES
.PP
One or more mouse axis values changed.
.TP
.B mouse.x (int)
x\-coordinate
.RS
.RE
.TP
.B mouse.y (int)
y\-coordinate
.RS
.RE
.TP
.B mouse.z (int)
z\-coordinate.
This usually means the vertical axis of a mouse wheel, where up is
positive and down is negative.
.RS
.RE
.TP
.B mouse.w (int)
w\-coordinate.
This usually means the horizontal axis of a mouse wheel.
.RS
.RE
.TP
.B mouse.dx (int)
Change in the x\-coordinate value since the previous
ALLEGRO_EVENT_MOUSE_AXES event.
.RS
.RE
.TP
.B mouse.dy (int)
Change in the y\-coordinate value since the previous
ALLEGRO_EVENT_MOUSE_AXES event.
.RS
.RE
.TP
.B mouse.dz (int)
Change in the z\-coordinate value since the previous
ALLEGRO_EVENT_MOUSE_AXES event.
.RS
.RE
.TP
.B mouse.dw (int)
Change in the w\-coordinate value since the previous
ALLEGRO_EVENT_MOUSE_AXES event.
.RS
.RE
.TP
.B mouse.display (ALLEGRO_DISPLAY *)
The display which had mouse focus.
.RS
.RE
.RS
.PP
\f[I]Note:\f[] Calling al_set_mouse_xy(3) also will result in a change
of axis values, but such a change is reported with
ALLEGRO_EVENT_MOUSE_WARPED events instead.
.RE
.RS
.PP
\f[I]Note:\f[] currently mouse.display may be NULL if an event is
generated in response to al_set_mouse_axis(3).
.RE
.SS ALLEGRO_EVENT_MOUSE_BUTTON_DOWN
.PP
A mouse button was pressed.
.TP
.B mouse.x (int)
x\-coordinate
.RS
.RE
.TP
.B mouse.y (int)
y\-coordinate
.RS
.RE
.TP
.B mouse.z (int)
z\-coordinate
.RS
.RE
.TP
.B mouse.w (int)
w\-coordinate
.RS
.RE
.TP
.B mouse.button (unsigned)
The mouse button which was pressed, numbering from 1.
.RS
.RE
.TP
.B mouse.display (ALLEGRO_DISPLAY *)
The display which had mouse focus.
.RS
.RE
.SS ALLEGRO_EVENT_MOUSE_BUTTON_UP
.PP
A mouse button was released.
.TP
.B mouse.x (int)
x\-coordinate
.RS
.RE
.TP
.B mouse.y (int)
y\-coordinate
.RS
.RE
.TP
.B mouse.z (int)
z\-coordinate
.RS
.RE
.TP
.B mouse.w (int)
w\-coordinate
.RS
.RE
.TP
.B mouse.button (unsigned)
The mouse button which was released, numbering from 1.
.RS
.RE
.TP
.B mouse.display (ALLEGRO_DISPLAY *)
The display which had mouse focus.
.RS
.RE
.SS ALLEGRO_EVENT_MOUSE_WARPED
.PP
al_set_mouse_xy(3) was called to move the mouse.
This event is identical to ALLEGRO_EVENT_MOUSE_AXES otherwise.
.SS ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY
.PP
The mouse cursor entered a window opened by the program.
.TP
.B mouse.x (int)
x\-coordinate
.RS
.RE
.TP
.B mouse.y (int)
y\-coordinate
.RS
.RE
.TP
.B mouse.z (int)
z\-coordinate
.RS
.RE
.TP
.B mouse.w (int)
w\-coordinate
.RS
.RE
.TP
.B mouse.display (ALLEGRO_DISPLAY *)
The display which had mouse focus.
.RS
.RE
.SS ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY
.PP
The mouse cursor leave the boundaries of a window opened by the program.
.TP
.B mouse.x (int)
x\-coordinate
.RS
.RE
.TP
.B mouse.y (int)
y\-coordinate
.RS
.RE
.TP
.B mouse.z (int)
z\-coordinate
.RS
.RE
.TP
.B mouse.w (int)
w\-coordinate
.RS
.RE
.TP
.B mouse.display (ALLEGRO_DISPLAY *)
The display which had mouse focus.
.RS
.RE
.SS ALLEGRO_EVENT_TIMER
.PP
A timer counter incremented.
.TP
.B timer.source (ALLEGRO_TIMER *)
The timer which generated the event.
.RS
.RE
.TP
.B timer.count (int64_t)
The timer count value.
.RS
.RE
.SS ALLEGRO_EVENT_DISPLAY_EXPOSE
.PP
The display (or a portion thereof) has become visible.
.TP
.B display.source (ALLEGRO_DISPLAY *)
The display which was exposed.
.RS
.RE
.TP
.B display.x (int)
\ 
.RS
.RE
.TP
.B display.y (int)
\ 
.RS
.RE
The top\-left corner of the display which was exposed.
.RS
.RE
.TP
.B display.width (int)
\ 
.RS
.RE
.TP
.B display.height (int)
The width and height of the rectangle which was exposed.
.RS
.RE
.RS
.PP
\f[I]Note:\f[] The display needs to be created with
ALLEGRO_GENERATE_EXPOSE_EVENTS flag for these events to be generated.
.RE
.SS ALLEGRO_EVENT_DISPLAY_RESIZE
.PP
The window has been resized.
.TP
.B display.source (ALLEGRO_DISPLAY *)
The display which was resized.
.RS
.RE
.TP
.B display.x (int)
\ 
.RS
.RE
.TP
.B display.y (int)
The position of the top\-level corner of the display.
.RS
.RE
.TP
.B display.width (int)
The new width of the display.
.RS
.RE
.TP
.B display.height (int)
The new height of the display.
.RS
.RE
.PP
You should normally respond to these events by calling
al_acknowledge_resize(3).
Note that further resize events may be generated by the time you process
the event, so these fields may hold outdated information.
.SS ALLEGRO_EVENT_DISPLAY_CLOSE
.PP
The close button of the window has been pressed.
.TP
.B display.source (ALLEGRO_DISPLAY *)
The display which was closed.
.RS
.RE
.SS ALLEGRO_EVENT_DISPLAY_LOST
.PP
When using Direct3D, displays can enter a "lost" state.
In that state, drawing calls are ignored, and upon entering the state,
bitmap\[aq]s pixel data can become undefined.
Allegro does its best to preserve the correct contents of bitmaps (see
ALLEGRO_NO_PRESERVE_TEXTURE) and restore them when the device is "found"
(see ALLEGRO_EVENT_DISPLAY_FOUND).
However, this is not 100% fool proof.
.PP
To ensure that all bitmap contents are restored accurately, one must
take additional steps.
The best procedure to follow if bitmap constancy is important to you is
as follows: first, always have the ALLEGRO_NO_PRESERVE_TEXTURE flag set
to true when creating bitmaps, as it incurs pointless overhead when
using this method.
Second, create a mechanism in your game for easily reloading all of your
bitmaps \-\- for example, wrap them in a class or data structure and
have a "bitmap manager" that can reload them back to the desired state.
Then, when you receive an ALLEGRO_EVENT_DISPLAY_FOUND event, tell the
bitmap manager (or whatever your mechanism is) to restore your bitmaps.
.TP
.B display.source (ALLEGRO_DISPLAY *)
The display which was lost.
.RS
.RE
.SS ALLEGRO_EVENT_DISPLAY_FOUND
.PP
Generated when a lost device is restored to operating state.
See ALLEGRO_EVENT_DISPLAY_LOST.
.TP
.B display.source (ALLEGRO_DISPLAY *)
The display which was found.
.RS
.RE
.SS ALLEGRO_EVENT_DISPLAY_SWITCH_OUT
.PP
The window is no longer active, that is the user might have clicked into
another window or "tabbed" away.
.TP
.B display.source (ALLEGRO_DISPLAY *)
The display which was switched out of.
.RS
.RE
.SS ALLEGRO_EVENT_DISPLAY_SWITCH_IN
.PP
The window is the active one again.
.TP
.B display.source (ALLEGRO_DISPLAY *)
The display which was switched into.
.RS
.RE
.SS ALLEGRO_EVENT_DISPLAY_ORIENTATION
.PP
Generated when the rotation or orientation of a display changes.
.TP
.B display.source (ALLEGRO_DISPLAY *)
The display which generated the event.
.RS
.RE
.TP
.B event.display.orientation
Contains one of the following values:
.RS
.IP \[bu] 2
ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES
.IP \[bu] 2
ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES
.IP \[bu] 2
ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES
.IP \[bu] 2
ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES
.IP \[bu] 2
ALLEGRO_DISPLAY_ORIENTATION_FACE_UP
.IP \[bu] 2
ALLEGRO_DISPLAY_ORIENTATION_FACE_DOWN
.RE
.SH SEE ALSO
.PP
ALLEGRO_EVENT_SOURCE(3), ALLEGRO_EVENT_TYPE(3), ALLEGRO_USER_EVENT(3),
ALLEGRO_GET_EVENT_TYPE(3)