12 ostream &operator <<(ostream &out, const SDL_Event &evt) {
14 #if SDL_VERSION_ATLEAST(2, 0, 4)
15 case SDL_AUDIODEVICEADDED:
16 out << "audio device added: " << evt.adevice;
18 case SDL_AUDIODEVICEREMOVED:
19 out << "audio device removed: " << evt.adevice;
22 case SDL_CONTROLLERAXISMOTION:
23 out << "controller axis motion: " << evt.caxis;
25 case SDL_CONTROLLERBUTTONDOWN:
26 out << "controller button down: " << evt.cbutton;
28 case SDL_CONTROLLERBUTTONUP:
29 out << "controller button up: " << evt.cbutton;
31 case SDL_CONTROLLERDEVICEADDED:
32 out << "controller device added: " << evt.cdevice;
34 case SDL_CONTROLLERDEVICEREMOVED:
35 out << "controller device removed: " << evt.cdevice;
37 case SDL_CONTROLLERDEVICEREMAPPED:
38 out << "controller device remapped: " << evt.cdevice;
40 case SDL_DOLLARGESTURE:
41 out << "dollar gesture: " << evt.dgesture;
43 case SDL_DOLLARRECORD:
44 out << "dollar record: " << evt.dgesture;
47 out << "drop file: " << evt.drop;
49 case SDL_FINGERMOTION:
50 out << "finger motion: " << evt.tfinger;
53 out << "finger down: " << evt.tfinger;
56 out << "finger up: " << evt.tfinger;
59 out << "key down: " << evt.key;
62 out << "key up: " << evt.key;
64 case SDL_JOYAXISMOTION:
65 out << "joystick axis motion: " << evt.jaxis;
67 case SDL_JOYBALLMOTION:
68 out << "joystick ball motion: " << evt.jball;
70 case SDL_JOYHATMOTION:
71 out << "joystick hat motion: " << evt.jhat;
73 case SDL_JOYBUTTONDOWN:
74 out << "joystick button down: " << evt.jbutton;
77 out << "joystick button up: " << evt.jbutton;
79 case SDL_JOYDEVICEADDED:
80 out << "joystick device added: " << evt.jdevice;
82 case SDL_JOYDEVICEREMOVED:
83 out << "joystick device removed: " << evt.jdevice;
86 out << "mouse motion: " << evt.motion;
88 case SDL_MOUSEBUTTONDOWN:
89 out << "mouse button down: " << evt.button;
91 case SDL_MOUSEBUTTONUP:
92 out << "mouse button up: " << evt.button;
95 out << "mouse wheel: " << evt.wheel;
97 case SDL_MULTIGESTURE:
98 out << "multi gesture: " << evt.mgesture;
101 out << "quit: " << evt.quit;
104 out << "sys wm: " << evt.syswm;
106 case SDL_TEXTEDITING:
107 out << "text editing: " << evt.edit;
110 out << "text input: " << evt.text;
113 out << "user: " << evt.user;
115 case SDL_WINDOWEVENT:
116 out << "window: " << evt.window;
125 ostream &operator <<(ostream &out, const SDL_WindowEvent &evt) {
127 case SDL_WINDOWEVENT_SHOWN:
128 out << "shown, window ID: " << evt.windowID;
130 case SDL_WINDOWEVENT_HIDDEN:
131 out << "hidden, window ID: " << evt.windowID;
133 case SDL_WINDOWEVENT_EXPOSED:
134 out << "exposed, window ID: " << evt.windowID;
136 case SDL_WINDOWEVENT_MOVED:
137 out << "moved, window ID: " << evt.windowID
138 << ", position: " << evt.data1 << ' ' << evt.data2;
140 case SDL_WINDOWEVENT_RESIZED:
141 out << "resized, window ID: " << evt.windowID
142 << ", size: " << evt.data1 << 'x' << evt.data2;
144 case SDL_WINDOWEVENT_SIZE_CHANGED:
145 out << "size changed, window ID: " << evt.windowID
146 << ", size: " << evt.data1 << 'x' << evt.data2;
148 case SDL_WINDOWEVENT_MINIMIZED:
149 out << "minimized, window ID: " << evt.windowID;
151 case SDL_WINDOWEVENT_MAXIMIZED:
152 out << "maximized, window ID: " << evt.windowID;
154 case SDL_WINDOWEVENT_RESTORED:
155 out << "restored, window ID: " << evt.windowID;
157 case SDL_WINDOWEVENT_ENTER:
158 out << "mouse entered, window ID: " << evt.windowID;
160 case SDL_WINDOWEVENT_LEAVE:
161 out << "mouse left, window ID: " << evt.windowID;
163 case SDL_WINDOWEVENT_FOCUS_GAINED:
164 out << "focus gained, window ID: " << evt.windowID;
166 case SDL_WINDOWEVENT_FOCUS_LOST:
167 out << "focus lost, window ID: " << evt.windowID;
169 case SDL_WINDOWEVENT_CLOSE:
170 out << "closed, window ID: " << evt.windowID;
179 ostream &operator <<(ostream &out, const SDL_KeyboardEvent &evt) {
180 out << "window ID: " << evt.windowID
181 << ", state: " << (evt.state == SDL_PRESSED ? "pressed" : "released")
182 << ", repeat: " << (evt.repeat ? "yes" : "no")
183 << ", keysym: " << evt.keysym;
187 ostream &operator <<(ostream &out, const SDL_Keysym &keysym) {
188 out << "scancode: " << int(keysym.scancode)
189 << ", sym: " << int(keysym.sym)
190 << " (\"" << SDL_GetKeyName(keysym.sym) << "\")";
193 if (keysym.mod & KMOD_LSHIFT) {
196 if (keysym.mod & KMOD_RSHIFT) {
199 if (keysym.mod & KMOD_LCTRL) {
202 if (keysym.mod & KMOD_RCTRL) {
205 if (keysym.mod & KMOD_LALT) {
208 if (keysym.mod & KMOD_RALT) {
211 if (keysym.mod & KMOD_LGUI) {
214 if (keysym.mod & KMOD_RGUI) {
217 if (keysym.mod & KMOD_NUM) {
220 if (keysym.mod & KMOD_CAPS) {
223 if (keysym.mod & KMOD_MODE) {
230 ostream &operator <<(ostream &out, const SDL_TextEditingEvent &evt) {
231 out << "window ID: " << evt.windowID
232 << ", text: \"" << evt.text
233 << "\", start: " << evt.start
234 << ", length: " << evt.length;
238 ostream &operator <<(ostream &out, const SDL_TextInputEvent &evt) {
239 out << "window ID: " << evt.windowID
240 << ", text: \"" << evt.text << '"';
244 ostream &operator <<(ostream &out, const SDL_MouseMotionEvent &evt) {
245 out << "window ID: " << evt.windowID
246 << ", mouse ID: " << evt.which
247 << ", position: " << evt.x << ' ' << evt.y
248 << ", delta: " << evt.xrel << ' ' << evt.yrel;
251 if (evt.state & SDL_BUTTON_LMASK) {
254 if (evt.state & SDL_BUTTON_MMASK) {
257 if (evt.state & SDL_BUTTON_RMASK) {
260 if (evt.state & SDL_BUTTON_X1MASK) {
263 if (evt.state & SDL_BUTTON_X2MASK) {
270 ostream &operator <<(ostream &out, const SDL_MouseButtonEvent &evt) {
271 out << "window ID: " << evt.windowID
272 << ", mouse ID: " << evt.which
274 switch (evt.button) {
275 case SDL_BUTTON_LEFT:
278 case SDL_BUTTON_MIDDLE:
281 case SDL_BUTTON_RIGHT:
291 out << int(evt.button);
294 out << ", state: " << (evt.state == SDL_PRESSED ? "pressed" : "released")
295 << ", clicks: " << int(evt.clicks)
296 << ", position: " << evt.x << ' ' << evt.y;
300 ostream &operator <<(ostream &out, const SDL_MouseWheelEvent &evt) {
301 out << "window ID: " << evt.windowID
302 << ", mouse ID: " << evt.which
303 << ", delta: " << evt.x << ' ' << evt.y
304 #if SDL_VERSION_ATLEAST(2, 0, 4)
305 << ", direction: " << (evt.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped")
311 ostream &operator <<(ostream &out, const SDL_JoyAxisEvent &evt) {
312 out << "joystick ID: " << evt.which
313 << ", axis ID: " << int(evt.axis)
314 << ", value: " << (float(evt.value) / 32768.0f);
318 ostream &operator <<(ostream &out, const SDL_JoyBallEvent &evt) {
319 out << "joystick ID: " << evt.which
320 << ", ball ID: " << int(evt.ball)
321 << ", delta: " << evt.xrel << ' ' << evt.yrel;
325 ostream &operator <<(ostream &out, const SDL_JoyHatEvent &evt) {
326 out << "joystick ID: " << evt.which
327 << ", hat ID: " << int(evt.hat)
336 case SDL_HAT_RIGHTUP:
342 case SDL_HAT_CENTERED:
348 case SDL_HAT_LEFTDOWN:
354 case SDL_HAT_RIGHTDOWN:
364 ostream &operator <<(ostream &out, const SDL_JoyButtonEvent &evt) {
365 out << "joystick ID: " << evt.which
366 << ", button ID: " << int(evt.button)
367 << ", state: " << (evt.state == SDL_PRESSED ? "pressed" : "released");
371 ostream &operator <<(ostream &out, const SDL_JoyDeviceEvent &evt) {
372 out << "joystick ID: " << evt.which;
376 ostream &operator <<(ostream &out, const SDL_ControllerAxisEvent &evt) {
377 out << "controller ID: " << evt.which
378 << ", axis ID: " << int(evt.axis)
379 << ", value: " << (float(evt.value) / 32768.0f);
383 ostream &operator <<(ostream &out, const SDL_ControllerButtonEvent &evt) {
384 out << "controller ID: " << evt.which
385 << ", button ID: " << int(evt.button)
386 << ", state: " << (evt.state == SDL_PRESSED ? "pressed" : "released");
390 ostream &operator <<(ostream &out, const SDL_ControllerDeviceEvent &evt) {
391 out << "controller ID: " << evt.which;
395 #if SDL_VERSION_ATLEAST(2, 0, 4)
396 ostream &operator <<(ostream &out, const SDL_AudioDeviceEvent &evt) {
397 out << "device ID: " << evt.which
398 << ", capture: " << (evt.iscapture ? "yes" : "no");
403 ostream &operator <<(ostream &out, const SDL_QuitEvent &evt) {
408 ostream &operator <<(ostream &out, const SDL_UserEvent &evt) {
409 out << "window ID: " << evt.windowID
410 << ", code: " << evt.code
411 << ", data 1: " << evt.data1
412 << ", data 2: " << evt.data2;
416 ostream &operator <<(ostream &out, const SDL_SysWMEvent &evt) {
418 out << "with message";
420 out << "without message";
425 ostream &operator <<(ostream &out, const SDL_TouchFingerEvent &evt) {
426 out << "device ID: " << evt.touchId
427 << ", finger ID: " << evt.fingerId
428 << ", position: " << evt.x << ' ' << evt.y
429 << ", delta: " << evt.dx << ' ' << evt.dy
430 << ", pressure: " << evt.pressure;
434 ostream &operator <<(ostream &out, const SDL_MultiGestureEvent &evt) {
435 out << "device ID: " << evt.touchId
436 << ", theta: " << evt.dTheta
437 << ", distance: " << evt.dDist
438 << ", position: " << evt.x << ' ' << evt.y
439 << ", fingers: " << evt.numFingers;
443 ostream &operator <<(ostream &out, const SDL_DollarGestureEvent &evt) {
444 out << "device ID: " << evt.touchId
445 << ", gesture ID: " << evt.gestureId
446 << ", fingers: " << evt.numFingers
447 << ", error: " << evt.error
448 << ", position: " << evt.x << ' ' << evt.y;
452 ostream &operator <<(ostream &out, const SDL_DropEvent &evt) {
453 out << "file: " << evt.file;