Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
994 lines (993 loc) · 13.2 KB

sdlevent.html

File metadata and controls

994 lines (993 loc) · 13.2 KB
 
Apr 26, 2001
Apr 26, 2001
1
2
3
4
5
6
<HTML
><HEAD
><TITLE
>SDL_Event</TITLE
><META
NAME="GENERATOR"
Feb 10, 2004
Feb 10, 2004
7
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
Apr 26, 2001
Apr 26, 2001
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"><LINK
REL="HOME"
TITLE="SDL Library Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="SDL Event Structures."
HREF="eventstructures.html"><LINK
REL="PREVIOUS"
TITLE="SDL Event Structures."
HREF="eventstructures.html"><LINK
REL="NEXT"
TITLE="SDL_ActiveEvent"
HREF="sdlactiveevent.html"></HEAD
><BODY
CLASS="REFENTRY"
BGCOLOR="#FFF8DC"
TEXT="#000000"
LINK="#0000ee"
VLINK="#551a8b"
ALINK="#ff0000"
><DIV
CLASS="NAVHEADER"
><TABLE
Feb 10, 2004
Feb 10, 2004
31
SUMMARY="Header navigation table"
Apr 26, 2001
Apr 26, 2001
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>SDL Library Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="eventstructures.html"
Feb 10, 2004
Feb 10, 2004
49
ACCESSKEY="P"
Apr 26, 2001
Apr 26, 2001
50
51
52
53
54
55
56
57
58
59
60
61
62
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sdlactiveevent.html"
Feb 10, 2004
Feb 10, 2004
63
ACCESSKEY="N"
Apr 26, 2001
Apr 26, 2001
64
65
66
67
68
69
70
71
72
73
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="SDLEVENT"
Feb 10, 2004
Feb 10, 2004
74
75
></A
>SDL_Event</H1
Apr 26, 2001
Apr 26, 2001
76
77
78
><DIV
CLASS="REFNAMEDIV"
><A
Feb 10, 2004
Feb 10, 2004
79
NAME="AEN3711"
Apr 26, 2001
Apr 26, 2001
80
81
82
83
84
85
86
></A
><H2
>Name</H2
>SDL_Event&nbsp;--&nbsp;General event structure</DIV
><DIV
CLASS="REFSECT1"
><A
Feb 10, 2004
Feb 10, 2004
87
NAME="AEN3714"
Apr 26, 2001
Apr 26, 2001
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
></A
><H2
>Structure Definition</H2
><PRE
CLASS="PROGRAMLISTING"
>typedef union{
Uint8 type;
SDL_ActiveEvent active;
SDL_KeyboardEvent key;
SDL_MouseMotionEvent motion;
SDL_MouseButtonEvent button;
SDL_JoyAxisEvent jaxis;
SDL_JoyBallEvent jball;
SDL_JoyHatEvent jhat;
SDL_JoyButtonEvent jbutton;
SDL_ResizeEvent resize;
Sep 14, 2001
Sep 14, 2001
104
SDL_ExposeEvent expose;
Apr 26, 2001
Apr 26, 2001
105
106
SDL_QuitEvent quit;
SDL_UserEvent user;
Dec 28, 2007
Dec 28, 2007
107
SDL_SysWMEvent syswm;
Apr 26, 2001
Apr 26, 2001
108
109
110
111
112
} SDL_Event;</PRE
></DIV
><DIV
CLASS="REFSECT1"
><A
Feb 10, 2004
Feb 10, 2004
113
NAME="AEN3717"
Apr 26, 2001
Apr 26, 2001
114
115
116
117
118
119
></A
><H2
>Structure Data</H2
><DIV
CLASS="INFORMALTABLE"
><A
Feb 10, 2004
Feb 10, 2004
120
NAME="AEN3719"
Apr 26, 2001
Apr 26, 2001
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
></A
><P
></P
><TABLE
BORDER="0"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>type</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
>The type of event</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>active</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlactiveevent.html"
>Activation event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>key</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlkeyboardevent.html"
>Keyboard event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>motion</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlmousemotionevent.html"
>Mouse motion event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>button</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlmousebuttonevent.html"
>Mouse button event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>jaxis</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoyaxisevent.html"
>Joystick axis motion event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>jball</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoyballevent.html"
>Joystick trackball motion event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>jhat</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoyhatevent.html"
>Joystick hat motion event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>jbutton</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoybuttonevent.html"
>Joystick button event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>resize</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlresizeevent.html"
>Application window resize event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
Sep 14, 2001
Sep 14, 2001
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
>expose</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlexposeevent.html"
>Application window expose event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
Apr 26, 2001
Apr 26, 2001
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
>quit</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlquitevent.html"
>Application quit request event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>user</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdluserevent.html"
>User defined event</A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="STRUCTFIELD"
><I
>syswm</I
></TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlsyswmevent.html"
>Undefined window manager event</A
></TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
></DIV
><DIV
CLASS="REFSECT1"
><A
Feb 10, 2004
Feb 10, 2004
386
NAME="AEN3791"
Apr 26, 2001
Apr 26, 2001
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
></A
><H2
>Description</H2
><P
>The <SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
> union is the core to all event handling is SDL, its probably the most important structure after <SPAN
CLASS="STRUCTNAME"
>SDL_Surface</SPAN
>. <SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
> is a union of all event structures used in SDL, using it is a simple matter of knowing which union member relates to which event <TT
CLASS="STRUCTFIELD"
><I
>type</I
></TT
>.</P
><P
><DIV
CLASS="INFORMALTABLE"
><A
Feb 10, 2004
Feb 10, 2004
410
NAME="AEN3799"
Apr 26, 2001
Apr 26, 2001
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
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
></A
><P
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="TOP"
>Event <TT
CLASS="STRUCTFIELD"
><I
>type</I
></TT
></TH
><TH
ALIGN="LEFT"
VALIGN="TOP"
>Event Structure</TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><TT
CLASS="LITERAL"
>SDL_ACTIVEEVENT</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><A
HREF="sdlactiveevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_ActiveEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_KEYDOWN/UP</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlkeyboardevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_KeyboardEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_MOUSEMOTION</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlmousemotionevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_MouseMotionEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_MOUSEBUTTONDOWN/UP</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlmousebuttonevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_MouseButtonEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_JOYAXISMOTION</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoyaxisevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_JoyAxisEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_JOYBALLMOTION</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoyballevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_JoyBallEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_JOYHATMOTION</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoyhatevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_JoyHatEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_JOYBUTTONDOWN/UP</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdljoybuttonevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_JoyButtonEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_QUIT</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlquitevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_QuitEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_SYSWMEVENT</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlsyswmevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_SysWMEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
>SDL_VIDEORESIZE</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlresizeevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_ResizeEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
Sep 14, 2001
Sep 14, 2001
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
>SDL_VIDEOEXPOSE</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdlexposeevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_ExposeEvent</SPAN
></A
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
><TT
CLASS="LITERAL"
Apr 26, 2001
Apr 26, 2001
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
>SDL_USEREVENT</TT
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><A
HREF="sdluserevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_UserEvent</SPAN
></A
></TD
></TR
></TBODY
></TABLE
><P
></P
></DIV
></P
></DIV
><DIV
CLASS="REFSECT1"
><A
Feb 10, 2004
Feb 10, 2004
692
NAME="AEN3885"
Apr 26, 2001
Apr 26, 2001
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
></A
><H2
>Use</H2
><P
>The <SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
> structure has two uses</P
><P
></P
><UL
COMPACT="COMPACT"
><LI
><P
>Reading events on the event queue</P
></LI
><LI
><P
>Placing events on the event queue</P
></LI
></UL
><P
>Reading events from the event queue is done with either <A
HREF="sdlpollevent.html"
><TT
CLASS="FUNCTION"
>SDL_PollEvent</TT
></A
> or <A
HREF="sdlpeepevents.html"
><TT
CLASS="FUNCTION"
>SDL_PeepEvents</TT
></A
>. We'll use <TT
CLASS="FUNCTION"
>SDL_PollEvent</TT
> and step through an example.</P
><P
>First off, we create an empty <SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
> structure.
<PRE
CLASS="PROGRAMLISTING"
>SDL_Event test_event;</PRE
>
<TT
CLASS="FUNCTION"
>SDL_PollEvent</TT
> removes the next event from the event queue, if there are no events on the queue it returns <SPAN
CLASS="RETURNVALUE"
>0</SPAN
> otherwise it returns <SPAN
CLASS="RETURNVALUE"
>1</SPAN
>. We use a <TT
CLASS="FUNCTION"
>while</TT
> loop to process each event in turn.
<PRE
CLASS="PROGRAMLISTING"
>while(SDL_PollEvent(&#38;test_event)) {</PRE
>
The <TT
CLASS="FUNCTION"
>SDL_PollEvent</TT
> function take a pointer to an <SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
> structure that is to be filled with event information. We know that if <TT
CLASS="FUNCTION"
>SDL_PollEvent</TT
> removes an event from the queue then the event information will be placed in our <SPAN
CLASS="STRUCTNAME"
>test_event</SPAN
Feb 10, 2004
Feb 10, 2004
769
770
771
> structure, but we also know that the <SPAN
CLASS="emphasis"
><I
Apr 26, 2001
Apr 26, 2001
772
773
CLASS="EMPHASIS"
>type</I
Feb 10, 2004
Feb 10, 2004
774
></SPAN
Apr 26, 2001
Apr 26, 2001
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
> of event will be placed in the <TT
CLASS="STRUCTFIELD"
><I
>type</I
></TT
> member of <SPAN
CLASS="STRUCTNAME"
>test_event</SPAN
>. So to handle each event <TT
CLASS="STRUCTFIELD"
><I
>type</I
></TT
> seperately we use a <TT
CLASS="FUNCTION"
>switch</TT
> statement.
<PRE
CLASS="PROGRAMLISTING"
> switch(test_event.type) {</PRE
>
Feb 10, 2004
Feb 10, 2004
796
797
798
We need to know what kind of events we're looking for <SPAN
CLASS="emphasis"
><I
Apr 26, 2001
Apr 26, 2001
799
800
CLASS="EMPHASIS"
>and</I
Feb 10, 2004
Feb 10, 2004
801
></SPAN
Apr 26, 2001
Apr 26, 2001
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
> the event <TT
CLASS="STRUCTFIELD"
><I
>type</I
></TT
>'s of those events. So lets assume we want to detect where the user is moving the mouse pointer within our application. We look through our event types and notice that <TT
CLASS="LITERAL"
>SDL_MOUSEMOTION</TT
> is, more than likely, the event we're looking for. A little <A
HREF="sdlmousemotionevent.html"
>more</A
> research tells use that <TT
CLASS="LITERAL"
>SDL_MOUSEMOTION</TT
> events are handled within the <A
HREF="sdlmousemotionevent.html"
><SPAN
CLASS="STRUCTNAME"
>SDL_MouseMotionEvent</SPAN
></A
> structure which is the <TT
CLASS="STRUCTFIELD"
><I
>motion</I
></TT
> member of <SPAN
CLASS="STRUCTNAME"
>SDL_Event</SPAN
>. We can check for the <TT
CLASS="LITERAL"
>SDL_MOUSEMOTION</TT
> event <TT
CLASS="STRUCTFIELD"
><I
>type</I
></TT
> within our <TT
CLASS="FUNCTION"
>switch</TT
> statement like so:
<PRE
CLASS="PROGRAMLISTING"
> case SDL_MOUSEMOTION:</PRE
>
All we need do now is read the information out of the <TT
CLASS="STRUCTFIELD"
><I
>motion</I
></TT
> member of <SPAN
CLASS="STRUCTNAME"
>test_event</SPAN
>.
<PRE
CLASS="PROGRAMLISTING"
> printf("We got a motion event.\n");
printf("Current mouse position is: (%d, %d)\n", test_event.motion.x, test_event.motion.y);
break;
default:
printf("Unhandled Event!\n");
break;
}
}
printf("Event queue empty.\n");</PRE
></P
><P
>It is also possible to push events onto the event queue and so use it as a two-way communication path. Both <A
HREF="sdlpushevent.html"
><TT
CLASS="FUNCTION"
>SDL_PushEvent</TT
></A
> and <A
HREF="sdlpeepevents.html"
><TT
CLASS="FUNCTION"
>SDL_PeepEvents</TT
></A
> allow you to place events onto the event queue. This is usually used to place a <TT
CLASS="LITERAL"
>SDL_USEREVENT</TT
> on the event queue, however you could use it to post fake input events if you wished. Creating your own events is a simple matter of choosing the event type you want, setting the <TT
CLASS="STRUCTFIELD"
><I
>type</I
></TT
> member and filling the appropriate member structure with information.
<PRE
CLASS="PROGRAMLISTING"
>SDL_Event user_event;
user_event.type=SDL_USEREVENT;
user_event.user.code=2;
user_event.user.data1=NULL;
user_event.user.data2=NULL;
SDL_PushEvent(&#38;user_event);</PRE
></P
></DIV
><DIV
CLASS="REFSECT1"
><A
Feb 10, 2004
Feb 10, 2004
903
NAME="AEN3942"
Apr 26, 2001
Apr 26, 2001
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
></A
><H2
>See Also</H2
><P
><A
HREF="sdlpollevent.html"
><TT
CLASS="FUNCTION"
>SDL_PollEvent</TT
></A
>,
<A
HREF="sdlpushevent.html"
><TT
CLASS="FUNCTION"
>SDL_PushEvent</TT
></A
>,
<A
HREF="sdlpeepevents.html"
><TT
CLASS="FUNCTION"
>SDL_PeepEvents</TT
></A
></P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
Feb 10, 2004
Feb 10, 2004
935
SUMMARY="Footer navigation table"
Apr 26, 2001
Apr 26, 2001
936
937
938
939
940
941
942
943
944
945
946
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="eventstructures.html"
Feb 10, 2004
Feb 10, 2004
947
ACCESSKEY="P"
Apr 26, 2001
Apr 26, 2001
948
949
950
951
952
953
954
955
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
Feb 10, 2004
Feb 10, 2004
956
ACCESSKEY="H"
Apr 26, 2001
Apr 26, 2001
957
958
959
960
961
962
963
964
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sdlactiveevent.html"
Feb 10, 2004
Feb 10, 2004
965
ACCESSKEY="N"
Apr 26, 2001
Apr 26, 2001
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>SDL Event Structures.</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="eventstructures.html"
Feb 10, 2004
Feb 10, 2004
981
ACCESSKEY="U"
Apr 26, 2001
Apr 26, 2001
982
983
984
985
986
987
988
989
990
991
992
993
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>SDL_ActiveEvent</TD
></TR
></TABLE
></DIV
></BODY
></HTML
Dec 28, 2007
Dec 28, 2007
994
>