comparison src/video/picogui/SDL_pgevents.c @ 1895:c121d94672cb

SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 10 Jul 2006 21:04:37 +0000
parents d910939febfa
children
comparison
equal deleted inserted replaced
1894:c69cee13dd76 1895:c121d94672cb
28 #include "../../events/SDL_sysevents.h" 28 #include "../../events/SDL_sysevents.h"
29 #include "../../events/SDL_events_c.h" 29 #include "../../events/SDL_events_c.h"
30 #include "SDL_pgvideo.h" 30 #include "SDL_pgvideo.h"
31 #include "SDL_pgevents_c.h" 31 #include "SDL_pgevents_c.h"
32 32
33 int PG_HandleClose(struct pgEvent *evt) 33 int
34 PG_HandleClose(struct pgEvent *evt)
34 { 35 {
35 SDL_PrivateQuit(); 36 SDL_PrivateQuit();
36 return 1; /* Intercept the event's normal quit handling */ 37 return 1; /* Intercept the event's normal quit handling */
37 } 38 }
38 39
39 int PG_HandleResize(struct pgEvent *evt) 40 int
41 PG_HandleResize(struct pgEvent *evt)
40 { 42 {
41 SDL_PrivateResize(evt->e.size.w, evt->e.size.h); 43 SDL_PrivateResize(evt->e.size.w, evt->e.size.h);
42 return 0; 44 return 0;
43 } 45 }
44 46
45 int PG_HandleKey(struct pgEvent *evt) 47 int
48 PG_HandleKey(struct pgEvent *evt)
46 { 49 {
47 SDL_keysym sym; 50 SDL_keysym sym;
48 SDL_memset(&sym,0,sizeof(sym)); 51 SDL_memset(&sym, 0, sizeof(sym));
49 sym.sym = evt->e.kbd.key; 52 sym.sym = evt->e.kbd.key;
50 sym.mod = evt->e.kbd.mods; 53 sym.mod = evt->e.kbd.mods;
51 SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym); 54 SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym);
52 return 0; 55 return 0;
53 } 56 }
54 57
55 int PG_HandleChar(struct pgEvent *evt) 58 int
59 PG_HandleChar(struct pgEvent *evt)
56 { 60 {
57 SDL_keysym sym; 61 SDL_keysym sym;
58 SDL_memset(&sym,0,sizeof(sym)); 62 SDL_memset(&sym, 0, sizeof(sym));
59 sym.unicode = evt->e.kbd.key; 63 sym.unicode = evt->e.kbd.key;
60 sym.mod = evt->e.kbd.mods; 64 sym.mod = evt->e.kbd.mods;
61 SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym); 65 SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym);
62 return 0; 66 return 0;
63 } 67 }
64 68
65 int PG_HandleMouseButton(struct pgEvent *evt) 69 int
66 { 70 PG_HandleMouseButton(struct pgEvent *evt)
67 /* We need to focus the canvas when it's clicked */ 71 {
68 if (evt->extra) { 72 /* We need to focus the canvas when it's clicked */
69 SDL_VideoDevice *this = (SDL_VideoDevice *) evt->extra; 73 if (evt->extra) {
70 pgFocus(this->hidden->wCanvas); 74 SDL_VideoDevice *this = (SDL_VideoDevice *) evt->extra;
71 } 75 pgFocus(this->hidden->wCanvas);
72 SDL_PrivateMouseButton(evt->type == PG_WE_PNTR_DOWN, evt->e.pntr.chbtn, 76 }
73 evt->e.pntr.x, evt->e.pntr.y); 77 SDL_PrivateMouseButton(evt->type == PG_WE_PNTR_DOWN, evt->e.pntr.chbtn,
74 return 0; 78 evt->e.pntr.x, evt->e.pntr.y);
79 return 0;
75 } 80 }
76 81
77 int PG_HandleMouseMotion(struct pgEvent *evt) 82 int
83 PG_HandleMouseMotion(struct pgEvent *evt)
78 { 84 {
79 SDL_PrivateMouseMotion(evt->e.pntr.btn,0,evt->e.pntr.x, evt->e.pntr.y); 85 SDL_PrivateMouseMotion(evt->e.pntr.btn, 0, evt->e.pntr.x, evt->e.pntr.y);
80 return 0; 86 return 0;
81 } 87 }
82 88
83 void PG_PumpEvents(_THIS) 89 void
90 PG_PumpEvents(_THIS)
84 { 91 {
85 /* Process all pending events */ 92 /* Process all pending events */
86 pgEventPoll(); 93 pgEventPoll();
87 } 94 }
88 95
89 void PG_InitOSKeymap(_THIS) 96 void
97 PG_InitOSKeymap(_THIS)
90 { 98 {
91 /* We need no keymap */ 99 /* We need no keymap */
92 } 100 }
93 101
94 void PG_InitEvents(_THIS) 102 void
103 PG_InitEvents(_THIS)
95 { 104 {
96 /* Turn on all the mouse and keyboard triggers for our canvas, normally less important 105 /* Turn on all the mouse and keyboard triggers for our canvas, normally less important
97 * events like mouse movement are ignored to save bandwidth. */ 106 * events like mouse movement are ignored to save bandwidth. */
98 pgSetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK, 107 pgSetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK,
99 pgGetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK) | 108 pgGetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK) |
100 PG_TRIGGER_UP | PG_TRIGGER_DOWN | PG_TRIGGER_MOVE | 109 PG_TRIGGER_UP | PG_TRIGGER_DOWN | PG_TRIGGER_MOVE |
101 PG_TRIGGER_KEYUP | PG_TRIGGER_KEYDOWN | PG_TRIGGER_CHAR,0); 110 PG_TRIGGER_KEYUP | PG_TRIGGER_KEYDOWN | PG_TRIGGER_CHAR, 0);
102 111
103 /* Start our canvas out focused, so we get keyboard input */ 112 /* Start our canvas out focused, so we get keyboard input */
104 pgFocus(this->hidden->wCanvas); 113 pgFocus(this->hidden->wCanvas);
105 114
106 /* Set up bindings for all the above event handlers */ 115 /* Set up bindings for all the above event handlers */
107 pgBind(this->hidden->wApp, PG_WE_CLOSE, &PG_HandleClose, NULL); 116 pgBind(this->hidden->wApp, PG_WE_CLOSE, &PG_HandleClose, NULL);
108 pgBind(this->hidden->wCanvas, PG_WE_BUILD, &PG_HandleResize, NULL); 117 pgBind(this->hidden->wCanvas, PG_WE_BUILD, &PG_HandleResize, NULL);
109 pgBind(this->hidden->wCanvas, PG_WE_KBD_CHAR, &PG_HandleChar, NULL); 118 pgBind(this->hidden->wCanvas, PG_WE_KBD_CHAR, &PG_HandleChar, NULL);
110 pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYUP, &PG_HandleKey, NULL); 119 pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYUP, &PG_HandleKey, NULL);
111 pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYDOWN, &PG_HandleKey, NULL); 120 pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYDOWN, &PG_HandleKey, NULL);
112 pgBind(this->hidden->wCanvas, PG_WE_PNTR_MOVE, &PG_HandleMouseMotion, NULL); 121 pgBind(this->hidden->wCanvas, PG_WE_PNTR_MOVE, &PG_HandleMouseMotion,
113 pgBind(this->hidden->wCanvas, PG_WE_PNTR_UP, &PG_HandleMouseButton, NULL); 122 NULL);
114 pgBind(this->hidden->wCanvas, PG_WE_PNTR_DOWN, &PG_HandleMouseButton, this); 123 pgBind(this->hidden->wCanvas, PG_WE_PNTR_UP, &PG_HandleMouseButton, NULL);
124 pgBind(this->hidden->wCanvas, PG_WE_PNTR_DOWN, &PG_HandleMouseButton,
125 this);
115 } 126 }
116 127
117 /* end of SDL_pgevents.c ... */ 128 /* end of SDL_pgevents.c ... */
129 /* vi: set ts=4 sw=4 expandtab: */