11 ostream &operator <<(ostream &out, const SDL_Event &evt) {
13 #if SDL_VERSION_ATLEAST(2, 0, 4)
14 case SDL_AUDIODEVICEADDED:
15 out << "audio device added: " << evt.adevice;
17 case SDL_AUDIODEVICEREMOVED:
18 out << "audio device removed: " << evt.adevice;
21 case SDL_CONTROLLERAXISMOTION:
22 out << "controller axis motion: " << evt.caxis;
24 case SDL_CONTROLLERBUTTONDOWN:
25 out << "controller button down: " << evt.cbutton;
27 case SDL_CONTROLLERBUTTONUP:
28 out << "controller button up: " << evt.cbutton;
30 case SDL_CONTROLLERDEVICEADDED:
31 out << "controller device added: " << evt.cdevice;
33 case SDL_CONTROLLERDEVICEREMOVED:
34 out << "controller device removed: " << evt.cdevice;
36 case SDL_CONTROLLERDEVICEREMAPPED:
37 out << "controller device remapped: " << evt.cdevice;
39 case SDL_DOLLARGESTURE:
40 out << "dollar gesture: " << evt.dgesture;
42 case SDL_DOLLARRECORD:
43 out << "dollar record: " << evt.dgesture;
46 out << "drop file: " << evt.drop;
48 case SDL_FINGERMOTION:
49 out << "finger motion: " << evt.tfinger;
52 out << "finger down: " << evt.tfinger;
55 out << "finger up: " << evt.tfinger;
58 out << "key down: " << evt.key;
61 out << "key up: " << evt.key;
63 case SDL_JOYAXISMOTION:
64 out << "joystick axis motion: " << evt.jaxis;
66 case SDL_JOYBALLMOTION:
67 out << "joystick ball motion: " << evt.jball;
69 case SDL_JOYHATMOTION:
70 out << "joystick hat motion: " << evt.jhat;
72 case SDL_JOYBUTTONDOWN:
73 out << "joystick button down: " << evt.jbutton;
76 out << "joystick button up: " << evt.jbutton;
78 case SDL_JOYDEVICEADDED:
79 out << "joystick device added: " << evt.jdevice;
81 case SDL_JOYDEVICEREMOVED:
82 out << "joystick device removed: " << evt.jdevice;
85 out << "mouse motion: " << evt.motion;
87 case SDL_MOUSEBUTTONDOWN:
88 out << "mouse button down: " << evt.button;
90 case SDL_MOUSEBUTTONUP:
91 out << "mouse button up: " << evt.button;
94 out << "mouse wheel: " << evt.wheel;
96 case SDL_MULTIGESTURE:
97 out << "multi gesture: " << evt.mgesture;
100 out << "quit: " << evt.quit;
103 out << "sys wm: " << evt.syswm;
105 case SDL_TEXTEDITING:
106 out << "text editing: " << evt.edit;
109 out << "text input: " << evt.text;
112 out << "user: " << evt.user;
114 case SDL_WINDOWEVENT:
115 out << "window: " << evt.window;
124 ostream &operator <<(ostream &out, const SDL_WindowEvent &evt) {
126 case SDL_WINDOWEVENT_SHOWN:
127 out << "shown, window ID: " << evt.windowID;
129 case SDL_WINDOWEVENT_HIDDEN:
130 out << "hidden, window ID: " << evt.windowID;
132 case SDL_WINDOWEVENT_EXPOSED:
133 out << "exposed, window ID: " << evt.windowID;
135 case SDL_WINDOWEVENT_MOVED:
136 out << "moved, window ID: " << evt.windowID
137 << ", position: " << evt.data1 << '+' << evt.data2;
139 case SDL_WINDOWEVENT_RESIZED:
140 out << "resized, window ID: " << evt.windowID
141 << ", size: " << evt.data1 << 'x' << evt.data2;
143 case SDL_WINDOWEVENT_SIZE_CHANGED:
144 out << "size changed, window ID: " << evt.windowID
145 << ", size: " << evt.data1 << 'x' << evt.data2;
147 case SDL_WINDOWEVENT_MINIMIZED:
148 out << "minimized, window ID: " << evt.windowID;
150 case SDL_WINDOWEVENT_MAXIMIZED:
151 out << "maximized, window ID: " << evt.windowID;
153 case SDL_WINDOWEVENT_RESTORED:
154 out << "restored, window ID: " << evt.windowID;
156 case SDL_WINDOWEVENT_ENTER:
157 out << "mouse entered, window ID: " << evt.windowID;
159 case SDL_WINDOWEVENT_LEAVE:
160 out << "mouse left, window ID: " << evt.windowID;
162 case SDL_WINDOWEVENT_FOCUS_GAINED:
163 out << "focus gained, window ID: " << evt.windowID;
165 case SDL_WINDOWEVENT_FOCUS_LOST:
166 out << "focus lost, window ID: " << evt.windowID;
168 case SDL_WINDOWEVENT_CLOSE:
169 out << "closed, window ID: " << evt.windowID;
178 ostream &operator <<(ostream &out, const SDL_KeyboardEvent &evt) {
179 out << "window ID: " << evt.windowID
180 << ", state: " << (evt.state == SDL_PRESSED ? "pressed" : "released")
181 << ", repeat: " << (evt.repeat ? "yes" : "no")
182 << ", keysym: " << evt.keysym;
186 ostream &operator <<(ostream &out, const SDL_Keysym &keysym) {
187 out << "scancode: " << int(keysym.scancode)
188 << ", sym: " << int(keysym.sym);
189 if (std::isprint(keysym.sym)) {
190 out << " (\"" << char(keysym.sym) << "\")";
194 if (keysym.mod & KMOD_LSHIFT) {
197 if (keysym.mod & KMOD_RSHIFT) {
200 if (keysym.mod & KMOD_LCTRL) {
203 if (keysym.mod & KMOD_RCTRL) {
206 if (keysym.mod & KMOD_LALT) {
209 if (keysym.mod & KMOD_RALT) {
212 if (keysym.mod & KMOD_LGUI) {
215 if (keysym.mod & KMOD_RGUI) {
218 if (keysym.mod & KMOD_NUM) {
221 if (keysym.mod & KMOD_CAPS) {
224 if (keysym.mod & KMOD_MODE) {
231 ostream &operator <<(ostream &out, const SDL_TextEditingEvent &evt) {
232 out << "window ID: " << evt.windowID
233 << ", text: \"" << evt.text
234 << "\", start: " << evt.start
235 << ", length: " << evt.length;
239 ostream &operator <<(ostream &out, const SDL_TextInputEvent &evt) {
240 out << "window ID: " << evt.windowID
241 << ", text: \"" << evt.text << '"';
245 ostream &operator <<(ostream &out, const SDL_MouseMotionEvent &evt) {
246 out << "window ID: " << evt.windowID
247 << ", mouse ID: " << evt.which
248 << ", position: " << evt.x << '+' << evt.y
249 << ", delta: " << evt.xrel << '+' << evt.yrel;
252 if (evt.state & SDL_BUTTON_LMASK) {
255 if (evt.state & SDL_BUTTON_MMASK) {
258 if (evt.state & SDL_BUTTON_RMASK) {
261 if (evt.state & SDL_BUTTON_X1MASK) {
264 if (evt.state & SDL_BUTTON_X2MASK) {
271 ostream &operator <<(ostream &out, const SDL_MouseButtonEvent &evt) {
272 out << "window ID: " << evt.windowID
273 << ", mouse ID: " << evt.which
275 switch (evt.button) {
276 case SDL_BUTTON_LEFT:
279 case SDL_BUTTON_MIDDLE:
282 case SDL_BUTTON_RIGHT:
292 out << int(evt.button);
295 out << ", state: " << (evt.state == SDL_PRESSED ? "pressed" : "released")
296 << ", clicks: " << int(evt.clicks)
297 << ", position: " << evt.x << '+' << evt.y;
301 ostream &operator <<(ostream &out, const SDL_MouseWheelEvent &evt) {
302 out << "window ID: " << evt.windowID
303 << ", mouse ID: " << evt.which
304 << ", delta: " << evt.x << '+' << evt.y
305 #if SDL_VERSION_ATLEAST(2, 0, 4)
306 << ", direction: " << (evt.direction == SDL_MOUSEWHEEL_NORMAL ? "normal" : "flipped")
312 ostream &operator <<(ostream &out, const SDL_JoyAxisEvent &evt) {
313 out << "joystick ID: " << evt.which
314 << ", axis ID: " << int(evt.axis)
315 << ", value: " << (float(evt.value) / 32768.0f);
319 ostream &operator <<(ostream &out, const SDL_JoyBallEvent &evt) {
320 out << "joystick ID: " << evt.which
321 << ", ball ID: " << int(evt.ball)
322 << ", delta: " << evt.xrel << '+' << evt.yrel;
326 ostream &operator <<(ostream &out, const SDL_JoyHatEvent &evt) {
327 out << "joystick ID: " << evt.which
328 << ", hat ID: " << int(evt.hat)
337 case SDL_HAT_RIGHTUP:
343 case SDL_HAT_CENTERED:
349 case SDL_HAT_LEFTDOWN:
355 case SDL_HAT_RIGHTDOWN:
365 ostream &operator <<(ostream &out, const SDL_JoyButtonEvent &evt) {
366 out << "joystick ID: " << evt.which
367 << ", button ID: " << int(evt.button)
368 << ", state: " << (evt.state == SDL_PRESSED ? "pressed" : "released");
372 ostream &operator <<(ostream &out, const SDL_JoyDeviceEvent &evt) {
373 out << "joystick ID: \"" << evt.which;
377 ostream &operator <<(ostream &out, const SDL_ControllerAxisEvent &evt) {
378 out << "controller ID: " << evt.which
379 << ", axis ID: " << int(evt.axis)
380 << ", value: " << (float(evt.value) / 32768.0f);
384 ostream &operator <<(ostream &out, const SDL_ControllerButtonEvent &evt) {
385 out << "controller ID: " << evt.which
386 << ", button ID: " << int(evt.button)
387 << ", state: " << (evt.state == SDL_PRESSED ? "pressed" : "released");
391 ostream &operator <<(ostream &out, const SDL_ControllerDeviceEvent &evt) {
392 out << "controller ID: " << evt.which;
396 #if SDL_VERSION_ATLEAST(2, 0, 4)
397 ostream &operator <<(ostream &out, const SDL_AudioDeviceEvent &evt) {
398 out << "device ID: " << evt.which
399 << ", capture: " << (evt.iscapture ? "yes" : "no");
404 ostream &operator <<(ostream &out, const SDL_QuitEvent &evt) {
409 ostream &operator <<(ostream &out, const SDL_UserEvent &evt) {
410 out << "window ID: " << evt.windowID
411 << ", code: " << evt.code
412 << ", data 1: " << evt.data1
413 << ", data 2: " << evt.data2;
417 ostream &operator <<(ostream &out, const SDL_SysWMEvent &evt) {
419 out << "with message";
421 out << "without message";
426 ostream &operator <<(ostream &out, const SDL_TouchFingerEvent &evt) {
427 out << "device ID: " << evt.touchId
428 << ", finger ID: " << evt.fingerId
429 << ", position: " << evt.x << ' ' << evt.y
430 << ", delta: " << evt.dx << ' ' << evt.dy
431 << ", pressure: " << evt.pressure;
435 ostream &operator <<(ostream &out, const SDL_MultiGestureEvent &evt) {
436 out << "device ID: " << evt.touchId
437 << ", theta: " << evt.dTheta
438 << ", distance: " << evt.dDist
439 << ", position: " << evt.x << ' ' << evt.y
440 << ", fingers: " << evt.numFingers;
444 ostream &operator <<(ostream &out, const SDL_DollarGestureEvent &evt) {
445 out << "device ID: " << evt.touchId
446 << ", gesture ID: " << evt.gestureId
447 << ", fingers: " << evt.numFingers
448 << ", error: " << evt.error
449 << ", position: " << evt.x << ' ' << evt.y;
453 ostream &operator <<(ostream &out, const SDL_DropEvent &evt) {
454 out << "file: " << evt.file;